affaan-m/ECC · error

requires a value

Error message

${flagName} requires a value

What it means

readArgValue in scripts/preview-pack-smoke.js extracts the value that follows a CLI flag and throws when the next token is missing or itself starts with '--'. This enforces that flags like --root or --format receive an actual value rather than silently consuming another flag or undefined.

Solutions

  1. Provide the value directly after the flag: `--root /path/to/dir`
  2. Check shell scripts for unset variables producing empty flag values
  3. Use the equals form if supported (e.g. --root=/path) to bind value to flag

Example fix

// before
node scripts/preview-pack-smoke.js --root
// after
node scripts/preview-pack-smoke.js --root /tmp/my-pack
Defensive patterns

Strategy: validation

Validate before calling

function validateFlagValue(argv, flag) {
  const i = argv.indexOf(flag);
  if (i === -1) return true;
  const v = argv[i + 1];
  return v !== undefined && !v.startsWith('--');
}

Try / catch

try {
  await main(process.argv);
} catch (e) {
  if (e.message.endsWith('requires a value')) {
    console.error(`${e.message}. Usage: <flag> <value>`);
    process.exitCode = 2;
  } else throw e;
}

Prevention

When it happens

Trigger: Running the script with a flag at the end of argv (no following token), e.g. `--root`, or with a value that looks like a flag, e.g. `--root --format json`.

Common situations: Typos where the flag value is forgotten; shell scripts building argv dynamically and dropping an empty variable; users writing `--root=--other-flag`-style confusion.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/65f8d1b1389817bf. Report an issue: GitHub.

Appendix: source

Thrown at scripts/preview-pack-smoke.js:97

];

function usage() {
  console.log([
    'Usage: node scripts/preview-pack-smoke.js [--format <text|json>] [--root <dir>]',
    '',
    'Deterministic smoke gate for the ECC 2.0 rc.1 preview pack.',
    '',
    'Options:',
    '  --format <text|json>  Output format (default: text)',
    '  --root <dir>          Repository root to inspect (default: cwd)',
    '  --help, -h            Show this help',
  ].join('\n'));
}

function readArgValue(args, index, flagName) {
  const value = args[index + 1];
  if (!value || value.startsWith('--')) {
    throw new Error(`${flagName} requires a value`);
  }
  return value;
}

function parseArgs(argv) {
  const args = argv.slice(2);
  const parsed = {
    format: 'text',
    help: false,
    root: path.resolve(process.cwd()),
  };

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

    if (arg === '--help' || arg === '-h') {
      parsed.help = true;
      continue;

View on GitHub (pinned to 8321021c54)