affaan-m/ECC · error · Error

Missing value for --version

Error message

Missing value for --version

What it means

Symmetric to the --action check: parseArgs demands a non-flag value right after --version. An absent or '--'-prefixed next argument means the version could not be read, so the parser throws before any ECC_VERSION_PATTERN validation happens.

Solutions

  1. Supply the version value immediately after --version, e.g. `--version 2.2.1`
  2. Ensure the version variable in your script/CI is set and non-empty
  3. Verify the version matches the expected pattern (see 'Invalid --version value')
  4. Use the action-only form if you don't need to pin a version

Example fix

// before
node scripts/welcome.js --action update --version
// after
node scripts/welcome.js --action update --version 2.2.1
Defensive patterns

Strategy: validation

Validate before calling

const versionIdx = process.argv.indexOf('--version');
const version = versionIdx !== -1 ? process.argv[versionIdx + 1] : undefined;
if (version === undefined || version.startsWith('--')) {
  throw new Error('Missing value for --version');
}

Type guard

function hasFlagValue(argv, flag) {
  const i = argv.indexOf(flag);
  return i !== -1 && typeof argv[i + 1] === 'string' && !argv[i + 1].startsWith('--');
}

Try / catch

try {
  parseArgs(process.argv.slice(2));
} catch (err) {
  if (err.message === 'Missing value for --version') {
    console.error('Provide a version after --version, e.g. --version 2.2.1');
    process.exit(2);
  }
  throw err;
}

Prevention

When it happens

Trigger: Invoking `node scripts/welcome.js --action install --version` (version omitted at end of argv) or `--version --action install` where the following token is another flag.

Common situations: Copy-pasting commands where the version placeholder was never filled in; CI matrices where a version variable is empty; combining flags in the wrong order assuming `=` syntax.

Understand the failure class

Background: "no subcommand specified" and "... is required": CLI errors when a required argument is missing — this error's family across 13 libraries.

Related errors


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

Appendix: source

Thrown at scripts/welcome.js:34

]);

function parseArgs(argv) {
  let action = 'installed';
  let version;

  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)) {

View on GitHub (pinned to 8321021c54)