affaan-m/ECC · error · Error

Unknown command

Error message

Unknown command: ${commandName}

What it means

runCommand() looks up commandName in the COMMANDS registry before spawning the script. A name absent from the registry throws 'Unknown command: <commandName>'. It is the dispatch guard for all subcommand execution.

Solutions

  1. Verify the command exists by checking the COMMANDS map in scripts/ecc.js or running `ecc --help`.
  2. Correct the invoked command name to a registered key.
  3. If invoked programmatically, guard with `if (COMMANDS[name])` before calling runCommand.

Example fix

// before
runCommand('instal', args)
// after
if (COMMANDS['install']) runCommand('install', args)
Defensive patterns

Strategy: try-catch

Validate before calling

if (!COMMANDS[commandName]) {
  console.error(`'${commandName}' is not a registered command. See ecc --help.`);
  process.exit(1);
}

Type guard

const isRegistered = (name) => Object.prototype.hasOwnProperty.call(COMMANDS, name);

Try / catch

try {
  process.exitCode = runCommand(name, args);
} catch (err) {
  if (/^Unknown command:/.test(err.message)) {
    showHelp(1);
  } else {
    throw err;
  }
}

Prevention

When it happens

Trigger: main() or the help-command resolution path calls runCommand('foo', ...) where 'foo' is not a key in COMMANDS in scripts/ecc.js.

Common situations: Stale shell completions or docs referencing removed commands, calling runCommand programmatically with an unregistered name, or a resolution bug passing an unvalidated string.

Related errors


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

Appendix: source

Thrown at scripts/ecc.js:267

    firstArg.startsWith('-')
    || knownLegacyLanguages.includes(firstArg)
  );

  if (!shouldTreatAsImplicitInstall) {
    throw new Error(`Unknown command: ${firstArg}`);
  }

  return {
    mode: 'command',
    command: 'install',
    args,
  };
}

function runCommand(commandName, args) {
  const command = COMMANDS[commandName];
  if (!command) {
    throw new Error(`Unknown command: ${commandName}`);
  }
  const isItoLogin = commandName === 'ito' && getInvocationCommand(args) === 'login';
  const result = spawnSync(
    process.execPath,
    [path.join(__dirname, command.script), ...args],
    {
      cwd: process.cwd(),
      env: commandName === 'ito'
        ? {
          ...createSafeItoInvocationEnvironment(process.env, args, {
            includeControls: true,
          }),
        }
        : process.env,
      stdio: isItoLogin || commandName === 'setup' || commandName === 'install'
        ? 'inherit'
        : commandName === 'memory'
          ? ['inherit', 'pipe', 'pipe']

View on GitHub (pinned to 8321021c54)