affaan-m/ECC · error · Error

Invalid --version value

Error message

Invalid --version value

What it means

When a --version value is provided, it must match ECC_VERSION_PATTERN (a regex describing accepted ECC version formats). Values that are present but malformed fail this final validation. Note the check only runs when version !== undefined, so omitting --version entirely is fine.

Solutions

  1. Inspect ECC_VERSION_PATTERN in scripts/welcome.js and format the version to match it exactly
  2. Try the canonical current version format (e.g. a semver string matching the pattern)
  3. Omit --version entirely if you don't need to pin one — it is optional
  4. Copy the version string from package.json or the latest release tag, then adjust to the pattern

Example fix

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

Strategy: validation

Validate before calling

const version = process.argv[process.argv.indexOf('--version') + 1];
if (version !== undefined && !ECC_VERSION_PATTERN.test(version)) {
  throw new Error(`Invalid --version value: ${version}`);
}

Type guard

function isValidEccVersion(value) {
  return typeof value === 'string' && ECC_VERSION_PATTERN.test(value);
}

Try / catch

try {
  parseArgs(process.argv.slice(2));
} catch (err) {
  if (err.message === 'Invalid --version value') {
    console.error(`Version must match ${ECC_VERSION_PATTERN}`);
    process.exit(2);
  }
  throw err;
}

Prevention

When it happens

Trigger: `node scripts/welcome.js --action install --version banana`, or versions with wrong formatting (missing 'v', extra suffixes, '2.2' vs expected pattern) that the ECC_VERSION_PATTERN regex rejects.

Common situations: Hand-typed versions with typos; pasting a tag like 'v2.2.1' when the pattern expects bare semver (or vice versa); scripts interpolating branch names or dates instead of versions.

Understand the failure class

Background: "unknown output mode", "invalid value for flag", "expects true/false": fixing invalid flag value errors in CLI tools — this error's family across 24 libraries.

Related errors


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

Appendix: source

Thrown at scripts/welcome.js:47

      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);
    process.stdout.write(renderTerminalWelcome({ action, color, version }));
  } catch (error) {
    process.stderr.write(`Error: ${error.message}\n`);
    process.exitCode = 1;
  }
}

if (require.main === module) {

View on GitHub (pinned to 8321021c54)