{"record":{"id":"7402ab8069d23570","repo":"nodejs/node","slug":"argv-2-not-recognized-7402ab","errorCode":null,"errorMessage":"${argv[2]} not recognized","messagePattern":"(.+?) not recognized","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"deps/npm/lib/commands/install-scripts.js","lineNumber":30,"sourceCode":"    'approve --all',\n    'deny <pkg> [<pkg> ...]',\n    'deny --all',\n    'ls',\n    'prune',\n  ]\n\n  static params = ['all', 'allow-scripts-pin', 'dry-run', 'json']\n\n  static async completion (opts) {\n    const argv = opts.conf.argv.remain\n    const subcommands = ['approve', 'deny', 'ls', 'prune']\n    if (argv.length === 2) {\n      return subcommands\n    }\n    if (subcommands.includes(argv[2])) {\n      return []\n    }\n    throw new Error(`${argv[2]} not recognized`)\n  }\n\n  async exec (args) {\n    const [sub, ...rest] = args\n    switch (sub) {\n      case 'approve':\n        return this.runMode('approve', rest)\n      case 'deny':\n        return this.runMode('deny', rest)\n      case 'ls':\n      case 'list':\n        return this.runMode('list', rest)\n      case 'prune':\n        return this.runMode('prune', rest)\n      default:\n        throw this.usageError(\n          sub ? `\\`${sub}\\` is not a recognized subcommand.` : undefined\n        )","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/npm/lib/commands/install-scripts.js#L12-L48","documentation":"During shell tab-completion for `npm install-scripts`, the static completion handler returns candidate subcommands for the first position and throws '<token> not recognized' for any token beyond that which is not in {approve, deny, ls, prune}. This is a completion-time guard, not raised by exec.","triggerScenarios":"Triggering completion (npm install-scripts <TAB>) with a token outside the valid set, or a programmatic completer passing an invalid subcommand.","commonSituations":"Stale shell completion cached from before install-scripts existed or after its subcommand set changed; wrappers invoking completion with arbitrary tokens.","solutions":["Use a valid subcommand: approve, deny, ls (list), or prune","Regenerate shell completion (`npm completion >> ~/.bashrc` / zsh equivalent) to refresh tokens","If calling completion programmatically, constrain candidates to the documented set"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const subcommands = ['approve', 'deny', 'ls', 'prune']\nif (!subcommands.includes(token)) { /* omit from completion candidates */ }","typeGuard":"function isInstallScriptsSubcommand(t) {\n  return ['approve', 'deny', 'ls', 'prune'].includes(t)\n}","tryCatchPattern":null,"preventionTips":["Refresh shell completion after npm upgrades","Constrain programmatic completion candidates to documented subcommands","Treat completion errors as non-fatal warnings"],"tags":["completion","install-scripts","cli","shell"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}