ReactiveX/rxjs · error · Error
Unknown mode: ${mode}
Error message
Unknown mode: ${mode} What it means
Thrown by parseArguments in the @rxjs/migrate CLI when the value passed to --mode is not one of the supported modes. The CLI only accepts 'cold' (RxJS 7-style cold observable semantics) or 'platform' (native Observable platform semantics); any other string aborts argument parsing before migration runs.
Source
Thrown at packages/migrate/src/cli.ts:140
for (let index = 0; index < argv.length; index++) {
const argument = argv[index];
if (!argument) continue;
switch (argument) {
case '--source-root':
options.sourceRoot = requiredValue(argv, ++index, argument);
break;
case '--out-dir':
options.outputRoot = requiredValue(argv, ++index, argument);
break;
case '--source-repo':
options.repository = requiredValue(argv, ++index, argument);
break;
case '--source-sha':
options.sha = requiredValue(argv, ++index, argument);
break;
case '--mode': {
const mode = requiredValue(argv, ++index, argument);
if (mode !== 'cold' && mode !== 'platform') throw new Error(`Unknown mode: ${mode}`);
options.mode = mode;
break;
}
case '--framework': {
const framework = requiredValue(argv, ++index, argument);
if (framework !== 'preserve' && framework !== 'mocha-chai-vitest') throw new Error(`Unknown framework: ${framework}`);
options.framework = framework;
break;
}
case '--write':
options.write = true;
break;
case '--help':
case '-h':
options.help = true;
break;
default:
if (argument.startsWith('-')) throw new Error(`Unknown option: ${argument}`);View on GitHub (pinned to 54796b38a5)
Solutions
- Set --mode to exactly 'cold' or 'platform'
- Run with --help to list accepted flag values
- Check for typos or trailing whitespace/shell quoting in the mode value
Example fix
// before npx @rxjs/migrate --mode hot --source-root src ... // after npx @rxjs/migrate --mode platform --source-root src ...
Defensive patterns
Strategy: validation
Validate before calling
const MODES = new Set(['cold', 'platform']);
if (!MODES.has(mode)) {
console.error(`--mode must be one of ${[...MODES].join(' | ')}`);
process.exitCode = 1;
} Type guard
const isMigrationMode = (v: string): v is 'cold' | 'platform' => v === 'cold' || v === 'platform';
Try / catch
try { runCli(argv); } catch (e) { console.error((e as Error).message); /* message already lists the offending value */ } Prevention
- Validate mode against a literal union before invoking the CLI
- Keep a typed options object so invalid modes fail at compile time in wrappers
When it happens
Trigger: Running the CLI with an invalid --mode value, e.g. `rxjs-migrate --mode hot ...`, `--mode rxjs8`, or a typo like `--mode platfrom`. Also triggered when the next token after --mode starts with '-' (via requiredValue) or is missing.
Common situations: Assuming mode names from older migration tooling or docs (e.g. 'v8', 'next', 'hot'), copy-pasting commands from an out-of-date migration guide, or shell quoting mistakes that shift the argument position.
Related errors
- Unknown framework: ${framework}
- Unknown option: ${argument}
- Missing required argument${missing.length === 1 ? '' : 's'}:
- --out-dir is required with --write
- ${option} requires a value
AI-assisted analysis of ReactiveX/rxjs@54796b38a5 (2026-08-28).
Data as JSON: /api/errors/dfa4dfad1882eb4a.
Report an issue: GitHub.