{"record":{"id":"b5499784739e6699","repo":"nodejs/node","slug":"argv-2-not-recognized-b54997","errorCode":null,"errorMessage":"${argv[2]} not recognized","messagePattern":"(.+?) not recognized","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"info","filePath":"deps/npm/lib/commands/org.js","lineNumber":30,"sourceCode":"    'ls orgname [<username>]',\n  ]\n\n  static params = ['registry', 'otp', 'json', 'parseable']\n\n  static async completion (opts) {\n    const argv = opts.conf.argv.remain\n    if (argv.length === 2) {\n      return ['set', 'rm', 'ls']\n    }\n\n    switch (argv[2]) {\n      case 'ls':\n      case 'add':\n      case 'rm':\n      case 'set':\n        return []\n      default:\n        throw new Error(argv[2] + ' not recognized')\n    }\n  }\n\n  async exec ([cmd, orgname, username, role]) {\n    return otplease(this.npm, {\n      ...this.npm.flatOptions,\n    }, opts => {\n      switch (cmd) {\n        case 'add':\n        case 'set':\n          return this.set(orgname, username, role, opts)\n        case 'rm':\n          return this.rm(orgname, username, opts)\n        case 'ls':\n          return this.ls(orgname, username, opts)\n        default:\n          throw this.usageError()\n      }","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/npm/lib/commands/org.js#L12-L48","documentation":"Thrown by the npm `org` command's shell-completion (autocomplete) handler when the subcommand word at argv[2] does not match any of the recognized values: ls, add, rm, set. The completion function returns suggestion arrays for known subcommands and throws for anything else. This only fires during tab-completion, not during normal command execution.","triggerScenarios":"Triggered when the shell invokes npm's completion machinery and the word being completed at position argv[2] is not one of 'ls', 'add', 'rm', or 'set'. For example, pressing tab after `npm org dele<TAB>` would pass 'dele' (or similar non-matching fragment) into the switch default.","commonSituations":"Developers rarely hit this directly — it surfaces in shell completion scripts (bash/zsh) that wire into `npm completion`. A misconfigured completion script, a stale shell completion cache, or a typo while tab-completing can cause it. Upgrading npm and not re-running `npm completion > ~/.bashrc` can leave stale completions.","solutions":["Re-run `npm completion >> ~/.bashrc` (or ~/.zshrc) to regenerate the completion script for your installed npm version","Verify the subcommand you are tab-completing is valid — only ls, add, rm, set are supported","Update npm to the latest stable version: `npm install -g npm@latest`","Restart your shell or `source ~/.bashrc` after regenerating completions"],"exampleFix":"// No code fix — this is a shell-completion path.\n// User fix: regenerate completions\n//   npm completion >> ~/.bashrc\n//   source ~/.bashrc","handlingStrategy":"validation","validationCode":"const VALID_ORG_SUBCOMMANDS = ['ls', 'add', 'rm', 'set']\nfunction isValidOrgSubcommand(cmd) {\n  return VALID_ORG_SUBCOMMANDS.includes(cmd)\n}\n// Before completion logic:\nif (!isValidOrgSubcommand(argv[2])) {\n  console.error(`Valid subcommands: ${VALID_ORG_SUBCOMMANDS.join(', ')}`)\n  process.exit(1)\n}","typeGuard":"function isOrgSubcommand(cmd) {\n  return typeof cmd === 'string' && ['ls', 'add', 'rm', 'set'].includes(cmd)\n}","tryCatchPattern":null,"preventionTips":["Regenerate shell completions after every npm upgrade: `npm completion >> ~/.bashrc`","Keep npm updated to ensure completion scripts match the installed version","When scripting npm org commands, validate subcommands against the known list before executing"],"tags":["npm","org","shell-completion","cli"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}