ReactiveX/rxjs · error · Error

Missing required argument${missing.length === 1 ? '' : 's'}:

Error message

Missing required argument${missing.length === 1 ? '' : 's'}: ${missing.join(', ')}

What it means

Thrown by validateArguments after parsing when one or more required inputs are absent: at least one source file, --source-root, --source-repo, and --source-sha. The message lists every missing item at once so you can fix them in one pass.

Source

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

      case '-h':
        options.help = true;
        break;
      default:
        if (argument.startsWith('-')) throw new Error(`Unknown option: ${argument}`);
        options.files.push(argument);
    }
  }
  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 {

View on GitHub (pinned to 54796b38a5)

Solutions

  1. Add all flags listed in the message: --source-root, --source-repo, --source-sha
  2. Pass at least one source file/glob as a positional argument
  3. Run with --help to see the full required syntax

Example fix

# before
npx @rxjs/migrate spec/app.spec.ts
# after
npx @rxjs/migrate --source-root . --source-repo https://github.com/org/repo --source-sha abc1234 spec/app.spec.ts
Defensive patterns

Strategy: validation

Validate before calling

const missing = [
  files.length === 0 && 'at least one source file',
  !sourceRoot && '--source-root',
  !repository && '--source-repo',
  !sha && '--source-sha',
].filter(Boolean);
if (missing.length) throw new Error('Missing: ' + missing.join(', '));

Type guard

const hasRequiredCliInput = (o: {files:string[]; sourceRoot?:string; repository?:string; sha?:string}) => o.files.length > 0 && !!o.sourceRoot && !!o.repository && !!o.sha;

Try / catch

try { runCli(argv); } catch (e) { console.error((e as Error).message); /* lists every missing item at once */ }

Prevention

When it happens

Trigger: Invoking the CLI without positional file arguments, or omitting any of --source-root, --source-repo, or --source-sha. Only fires when --help was not requested.

Common situations: First-time use without reading usage, partially copied example commands, or npm scripts that expect variables (${SHA}) that expand to empty strings.

Understand the failure class

Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.

Related errors


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