ReactiveX/rxjs · error · Error

${option} requires a value

Error message

${option} requires a value

What it means

Thrown by the requiredValue helper when an option that expects a value is either the last token on the command line or is followed by another flag-like token. It guards --source-root, --source-repo, --source-sha, --mode, --framework, and --out-dir from silently consuming nothing.

Source

Thrown at packages/migrate/src/cli.ts:178

    }
  }
  return options;
}

function validateArguments(options: CliOptions): asserts options is RunnableCliOptions {
  const missing = [
    options.files.length === 0 ? 'at least one source file' : undefined,
    options.sourceRoot ? undefined : '--source-root',
    options.repository ? undefined : '--source-repo',
    options.sha ? undefined : '--source-sha',
  ].filter((value): value is string => value !== undefined);
  if (missing.length > 0) throw new Error(`Missing required argument${missing.length === 1 ? '' : 's'}: ${missing.join(', ')}`);
  if (options.write && !options.outputRoot) throw new Error('--out-dir is required with --write');
}

function requiredValue(argv: readonly string[], index: number, option: string): string {
  const value = argv[index];
  if (!value || value.startsWith('-')) throw new Error(`${option} requires a value`);
  return value;
}

function errorReport(code: MigrationCliErrorReport['error']['code'], message: string): MigrationCliErrorReport {
  return { schemaVersion: migrationCliReportSchemaVersion, status: 'error', error: { code, message } };
}

function writeJson(stream: Pick<NodeJS.WriteStream, 'write'>, value: MigrationCliReport | MigrationCliErrorReport): void {
  stream.write(`${JSON.stringify(value, null, 2)}\n`);
}

function messageFor(error: unknown): string {
  return error instanceof Error ? error.message : String(error);
}

function usage(): string {
  return [
    'Usage: rxjs-migrate [options] <test files...>',

View on GitHub (pinned to 54796b38a5)

Solutions

  1. Supply a concrete value immediately after the option
  2. Check that shell variables used for values are non-empty (`echo "$SHA"`)
  3. Reorder the command so each value-taking flag is followed by its value

Example fix

# before
SHA=
npx @rxjs/migrate --source-sha "$SHA" ...
# after
SHA=$(git rev-parse HEAD)
npx @rxjs/migrate --source-sha "$SHA" ...
Defensive patterns

Strategy: validation

Validate before calling

const needsValue = new Set(['--source-root','--source-repo','--source-sha','--mode','--framework','--out-dir']);
for (let i = 0; i < argv.length; i++) {
  if (needsValue.has(argv[i]) && (!argv[i+1] || argv[i+1].startsWith('-'))) {
    throw new Error(`${argv[i]} is missing its value`);
  }
}

Type guard

const hasValue = (argv: string[], i: number) => Boolean(argv[i+1]) && !argv[i+1].startsWith('-');

Try / catch

try { runCli(argv); } catch (e) { console.error((e as Error).message); /* names the option lacking a value */ }

Prevention

When it happens

Trigger: Ending the command with a value-taking flag (`... --source-sha`), or following it with another flag (`--mode --write`), or an empty shell variable (`--source-sha "$SHA"` when SHA is unset becomes a later failure or flag-adjacent token).

Common situations: Unset environment variables in CI scripts, truncated copy-pasted commands, or reordering flags and dropping the value.

Related errors


AI-assisted analysis of ReactiveX/rxjs@54796b38a5 (2026-08-28). Data as JSON: /api/errors/f2c9afbee6bf3371. Report an issue: GitHub.