affaan-m/ECC · error · Error

Unknown command

Error message

Unknown command: ${resolution.command}

What it means

main throws when resolving a per-command help request for a command name not present in the COMMANDS map — i.e. `ecc <unknown-cmd> --help` (or an unregistered name reached resolveCommand's help path). The faulting input is resolution.command.

Solutions

  1. Run `ecc --help` to list valid commands.
  2. Fix the command name typo in the invocation or npm script.
  3. Register the command in COMMANDS (and package.json bin/files) if it is meant to exist.

Example fix

// before
$ ecc help instal
Error: Unknown command: instal
// after
$ ecc help install
Defensive patterns

Strategy: validation

Validate before calling

if (process.argv[2] === 'help') {
  const target = process.argv[3];
  if (target && !COMMANDS[target]) {
    console.error(`No such command: ${target}. See ecc --help.`);
    process.exit(1);
  }
}

Type guard

const hasCommand = (name) => typeof name === 'string' && !!COMMANDS[name];

Try / catch

try {
  main();
} catch (err) {
  if (/^Unknown command:/.test(err.message)) {
    showHelp(1);
  } else {
    throw err;
  }
}

Prevention

When it happens

Trigger: Running `ecc help <name>` or `ecc <name> --help` where <name> resolves through the help-command resolution path but is not a key in COMMANDS.

Common situations: Asking for help on a mistyped or removed command, old documentation referencing renamed commands, or shell completion suggesting stale command names.

Related errors


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

Appendix: source

Thrown at scripts/ecc.js:329

  return 1;
}

function main() {
  try {
    const resolution = resolveCommand(process.argv);

    if (resolution.mode === 'help') {
      showHelp(0);
    }

    if (resolution.mode === 'help-command') {
      if (!resolution.command) {
        showHelp(0);
      }

      if (!COMMANDS[resolution.command]) {
        throw new Error(`Unknown command: ${resolution.command}`);
      }

      process.exitCode = runCommand(resolution.command, ['--help']);
      return;
    }

    process.exitCode = runCommand(resolution.command, resolution.args);
  } catch (error) {
    console.error(`Error: ${error.message}`);
    process.exit(1);
  }
}

main();

View on GitHub (pinned to 8321021c54)