affaan-m/ECC · error · Error

Missing value for ${argument}

Error message

Missing value for ${argument}

What it means

Thrown by setup.js parseArgs when a value flag (--mode, --scope, --hooks) is followed by no token or by a token beginning with '--'. The parser will not consume a neighboring flag as the value, matching the ECC pattern of strict value-flag handling.

Source

Thrown at scripts/setup.js:84

    hooks: undefined,
    json: false,
    mode: undefined,
    moveScope: false,
    scope: undefined,
    yes: false,
  };
  const valueFlags = new Map([
    ['--mode', 'mode'],
    ['--scope', 'scope'],
    ['--hooks', 'hooks'],
  ]);

  for (let index = 0; index < argv.length; index += 1) {
    const argument = argv[index];
    if (valueFlags.has(argument)) {
      const value = argv[index + 1];
      if (!value || value.startsWith('--')) {
        throw new Error(`Missing value for ${argument}`);
      }
      options[valueFlags.get(argument)] = value;
      index += 1;
    } else if (argument === '--yes' || argument === '-y') {
      options.yes = true;
    } else if (argument === '--dry-run') {
      options.dryRun = true;
    } else if (argument === '--move-scope') {
      options.moveScope = true;
    } else if (argument === '--json') {
      options.json = true;
    } else if (argument === '--help' || argument === '-h') {
      options.help = true;
    } else {
      throw new Error(`Unknown argument: ${argument}`);
    }
  }

View on GitHub (pinned to 01e15490f0)

Solutions

  1. Provide the value immediately: `--scope user`.
  2. Ensure the value does not start with '--'; quote it if it contains special characters.
  3. Drop the flag if you want the interactive prompt to fill it.
  4. Re-check the help output for which flags require values.

Example fix

# before
node scripts/setup.js --scope --hooks standard
# after
node scripts/setup.js --scope user --hooks standard
Defensive patterns

Strategy: validation

Validate before calling

const VALUE_FLAGS = new Set(['--mode', '--scope', '--hooks']);
for (let i = 0; i < argv.length; i += 1) {
  if (VALUE_FLAGS.has(argv[i]) && (!argv[i + 1] || argv[i + 1].startsWith('--'))) {
    throw new Error(`Missing value for ${argv[i]}`);
  }
}

Try / catch

try { parseArgs(process.argv); } catch (err) { console.error(err.message); printHelp(); process.exit(2); }

Prevention

When it happens

Trigger: `node scripts/setup.js --scope` with nothing after; `--scope --hooks standard` (the second flag is read as scope's value and rejected); a value that was meant to be quoted but got dropped by the shell.

Common situations: Trailing flag at end of a CI command; reordering flags so value-flags collide; typos where a boolean flag is mistaken for a value flag.

Related errors


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