affaan-m/ECC · error · Error
Unknown argument
Error message
Unknown argument
What it means
welcome.js parseArgs implements an allowlist parser: only --action and --version are recognized. Any other argument (including unknown flags, stray positionals, or mistyped variants) hits the final else branch and throws 'Unknown argument'.
Solutions
- Remove the unrecognized argument from the command
- Check spelling — the parser is exact-match, no abbreviations or aliases
- Consult the script header/help to see the only supported flags: --action and --version
- If you intended a different script's flag set, run the correct script
Example fix
// before node scripts/welcome.js --action install --json // after node scripts/welcome.js --action install
Defensive patterns
Strategy: validation
Validate before calling
const ALLOWED = new Set(['--action', '--version']);
const unknown = process.argv.slice(2).filter(a => a.startsWith('--') && !ALLOWED.has(a));
if (unknown.length > 0) throw new Error(`Unknown argument(s): ${unknown.join(', ')}`); Type guard
function isKnownFlag(arg) {
return arg === '--action' || arg === '--version';
} Try / catch
try {
parseArgs(process.argv.slice(2));
} catch (err) {
if (err.message === 'Unknown argument') {
console.error('Only --action and --version are supported. Check spelling and script choice.');
process.exit(2);
}
throw err;
} Prevention
- Cross-check flags against the target script's help before reusing commands from other scripts
- Avoid abbreviations — the parser is exact-match
- Keep per-script command snippets in separate shell aliases to avoid flag bleed
- Version-control your wrapper scripts so flag drift is reviewable
When it happens
Trigger: Passing any token that is not exactly `--action` or `--version`, e.g. `node scripts/welcome.js --verbose`, `--acton install` (typo), or an unexpected positional word.
Common situations: Typos in flag names; flags copied from other ECC scripts (like --target or --json used here by mistake); shell expansion adding unexpected tokens; assuming shared flag conventions across scripts.
Understand the failure class
Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.
Related errors
- Unknown argument
- Unknown argument
- decisions does not accept a session ID when --all is set
- Invalid value: expected a path
- must use non-empty key=value form
AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16).
Data as JSON: /api/errors/99873232291a8853.
Report an issue: GitHub.
Appendix: source
Thrown at scripts/welcome.js:39
for (let index = 0; index < argv.length; index += 1) {
const argument = argv[index];
if (argument === '--action') {
const value = argv[index + 1];
if (!value || value.startsWith('--')) {
throw new Error('Missing value for --action');
}
action = value;
index += 1;
} else if (argument === '--version') {
const value = argv[index + 1];
if (!value || value.startsWith('--')) {
throw new Error('Missing value for --version');
}
version = value;
index += 1;
} else {
throw new Error('Unknown argument');
}
}
if (!VALID_ACTIONS.has(action)) {
throw new Error('Invalid --action value');
}
if (version !== undefined && !ECC_VERSION_PATTERN.test(version)) {
throw new Error('Invalid --version value');
}
return { action, version };
}
function main(argv = process.argv.slice(2)) {
try {
const { action, version } = parseArgs(argv);
const color = process.env.NO_COLOR === undefined
&& process.env.TERM !== 'dumb'
&& Boolean(process.stdout.isTTY);View on GitHub (pinned to 8321021c54)