moeru-ai/airi · error

Missing value for `${optionName}`.

Error message

Missing value for `${optionName}`.

What it means

readRequiredOptionValue reads viteArgs[index + 1] for a flag that needs a value (e.g. --config / -c) and throws when that value is missing/falsy. This protects against an option being the last token or followed by another flag, which would otherwise silently pass undefined downstream.

Source

Thrown at packages/cap-vite/src/index.ts:54

  return fileURLToPath(new URL(`./vite-wrapper-config${wrapperExtension}`, import.meta.url))
}

function parseViteConfigLoader(value: string | undefined): 'bundle' | 'native' | 'runner' | undefined {
  if (value === 'bundle' || value === 'native' || value === 'runner') {
    return value
  }

  return undefined
}

function resolveConfigPath(cwd: string, value: string): string {
  return resolve(cwd, value)
}

function readRequiredOptionValue(viteArgs: string[], index: number, optionName: string): string {
  const value = viteArgs[index + 1]
  if (!value) {
    throw new Error(`Missing value for \`${optionName}\`.`)
  }

  return value
}

function parseConfigArg(viteArgs: string[], index: number, cwd: string): ParsedViteArg | null {
  const arg = viteArgs[index]

  // NOTICE: Vite only accepts one `--config` entrypoint. cap-vite consumes that slot
  // for its wrapper config, then loads the user config from inside the wrapper.
  if (arg === '--config' || arg === '-c') {
    return {
      baseConfigFile: resolveConfigPath(cwd, readRequiredOptionValue(viteArgs, index, '--config')),
      consumedArgs: 2,
      forwardedArgs: [],
    }
  }

View on GitHub (pinned to 27111382b4)

Solutions

  1. Always supply a concrete value immediately after --config / -c.
  2. When building argv conditionally, push both the flag and its value together or skip both.
  3. Validate the assembled argv shape (flag followed by a non-flag, non-separator token) before running cap-vite.

Example fix

# before
cap-vite --config -- ios

# after
cap-vite --config ./vite.config.ts -- ios
Defensive patterns

Strategy: validation

Validate before calling

function ensureOptionValue(argv: string[], i: number, name: string) {
  const next = argv[i + 1]
  if (!next || next.startsWith('-') || next === '--') {
    throw new Error(`Option ${name} requires a value`)
  }
}

Try / catch

try {
  return readRequiredOptionValue(viteArgs, index, optionName)
}
catch (err) {
  if (/Missing value/i.test((err as Error).message)) {
    console.error(`Provide a value for ${optionName}`)
    process.exit(1)
  }
  throw err
}

Prevention

When it happens

Trigger: `cap-vite --config -- ios` where the value slot is occupied by the separator; `--config` as the final token; an empty-string value; an option flag followed immediately by another flag like `--config --mode`.

Common situations: Users omitting the config path; argv mis-sliced by a wrapping script; chaining multiple options and forgetting one value; CI templates that conditionally inject a flag without its value.

Related errors


AI-assisted analysis of moeru-ai/airi@27111382b4 (2026-08-12). Data as JSON: /api/errors/3023c951c7d88f46. Report an issue: GitHub.