affaan-m/ECC · error · Error

Unknown argument: ${arg}

Error message

Unknown argument: ${arg}

What it means

The argument parser in doctor.js accepts only three flags: --target (with a value), --json (boolean), and --help/-h (boolean). Any other token — including unknown flags, positional arguments, or typos — falls through to the else branch and throws. The --target flag is special: it pushes the next argument (or null) to an array, supporting multiple --target flags.

Source

Thrown at scripts/doctor.js:36

  const args = argv.slice(2);
  const parsed = {
    targets: [],
    json: false,
    help: false,
  };

  for (let index = 0; index < args.length; index += 1) {
    const arg = args[index];

    if (arg === '--target') {
      parsed.targets.push(args[index + 1] || null);
      index += 1;
    } else if (arg === '--json') {
      parsed.json = true;
    } else if (arg === '--help' || arg === '-h') {
      parsed.help = true;
    } else {
      throw new Error(`Unknown argument: ${arg}`);
    }
  }

  return parsed;
}

function statusLabel(status) {
  if (status === 'ok') {
    return 'OK';
  }

  if (status === 'warning') {
    return 'WARNING';
  }

  if (status === 'error') {
    return 'ERROR';
  }

View on GitHub (pinned to 01e15490f0)

Solutions

  1. Run `node scripts/doctor.js --help` to see the accepted flags
  2. Check for typos in flag names
  3. Note that --target expects a value from SUPPORTED_INSTALL_TARGETS (claude, claude-project, cursor, etc.)

Example fix

// before
node scripts/doctor.js --verbose
node scripts/doctor.js --format json
// after
node scripts/doctor.js --json --target claude
Defensive patterns

Strategy: validation

Validate before calling

// Pre-validate arguments against the accepted set
const ACCEPTED = new Set(['--target', '--json', '--help', '-h']);
const argv = process.argv.slice(2);
for (let i = 0; i < argv.length; i++) {
  const arg = argv[i];
  if (!ACCEPTED.has(arg)) {
    console.error(`Unknown argument: ${arg}`);
    console.error('Accepted: --target <name>, --json, --help');
    process.exit(1);
  }
  if (arg === '--target') i++; // skip the value
}

Try / catch

try {
  const options = parseArgs(process.argv);
} catch (error) {
  if (error.message.startsWith('Unknown argument:')) {
    console.error(error.message);
    console.error('doctor.js accepts only: --target <name>, --json, --help');
    process.exit(2);
  }
  throw error;
}

Prevention

When it happens

Trigger: Passing an unsupported flag like --verbose, --output, or --format; passing a positional argument; a typo such as --targe instead of --target; or passing --target without a value (which does not throw here but pushes null, potentially failing later).

Common situations: Confusing doctor.js flags with those of other ECC scripts (e.g. consult.js accepts different flags); CI configurations referencing flags from a different tool; users who assume common flags like --verbose exist across all scripts.

Related errors


AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13). Data as JSON: /api/errors/945d85dacd89d472. Report an issue: GitHub.