{"record":{"id":"9e55c02640bcba49","repo":"nodejs/node","slug":"argv-2-not-recognized-9e55c0","errorCode":null,"errorMessage":"${argv[2]} not recognized","messagePattern":"(.+?) not recognized","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"deps/npm/lib/commands/token.js","lineNumber":48,"sourceCode":"    'bypass-2fa',\n    'password',\n    'registry',\n    'otp',\n    'read-only',\n  ]\n\n  static async completion (opts) {\n    const argv = opts.conf.argv.remain\n    const subcommands = ['list', 'revoke', 'create']\n    if (argv.length === 2) {\n      return subcommands\n    }\n\n    if (subcommands.includes(argv[2])) {\n      return []\n    }\n\n    throw new Error(argv[2] + ' not recognized')\n  }\n\n  async exec (args) {\n    if (args.length === 0) {\n      return this.list()\n    }\n    switch (args[0]) {\n      case 'list':\n      case 'ls':\n        return this.list()\n      case 'rm':\n      case 'delete':\n      case 'revoke':\n      case 'remove':\n        return this.rm(args.slice(1))\n      case 'create':\n        return this.create(args.slice(1))\n      default:","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/npm/lib/commands/token.js#L30-L66","documentation":"Thrown by `npm token`'s shell-completion handler when the third argv token (the subcommand) is not one of `list`, `revoke`, `create`. Completion-time signal that the typed subcommand is unrecognized.","triggerScenarios":"Completion invoked with `argv.length > 2` and `argv[2]` not in `['list','revoke','create']` (e.g. tab-completing `npm token del`).","commonSituations":"Using `delete`/`rm`/`remove` at completion time; the runtime `exec` accepts aliases (`rm`, `delete`, `ls`) but the completion list only recognizes the canonical `list|revoke|create`.","solutions":["Tab-complete from the canonical set: `list`, `revoke`, `create`.","Note `exec` also accepts aliases (`ls` for list, `rm`/`delete` for revoke) at runtime, but completion matches the canonical names.","Run `npm token` with no subcommand to view usage."],"exampleFix":"// before\nnpm token delete <TAB>\n// after\nnpm token revoke <TAB>","handlingStrategy":"validation","validationCode":"const TOKEN_SUBCOMMANDS = ['list', 'revoke', 'create']\nfunction normalizeTokenCmd(cmd) {\n  // runtime aliases accepted by exec\n  if (cmd === 'ls') return 'list'\n  if (cmd === 'rm' || cmd === 'delete') return 'revoke'\n  return cmd\n}\nfunction assertTokenSubcommand(cmd) {\n  if (!['list', 'revoke', 'create', 'ls', 'rm', 'delete'].includes(cmd)) {\n    throw new Error(`Unknown npm token subcommand \"${cmd}\"`)\n  }\n}","typeGuard":"function isTokenSubcommand(cmd) {\n  return ['list', 'revoke', 'create', 'ls', 'rm', 'delete'].includes(cmd)\n}","tryCatchPattern":null,"preventionTips":["Prefer canonical names (list/revoke/create) for shell completion compatibility.","Validate the subcommand before invoking in automation.","Note completion only recognizes the canonical three, though runtime accepts aliases."],"tags":["token","completion","argument-validation","npm-cli"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}