nodejs/node · warning · Error

${argv[2]} not recognized

Error message

${argv[2]} not recognized

What it means

During shell tab-completion for `npm access`, the static completion handler returns the valid next tokens for known subcommands (grant/revoke/list/ls/get/set) but throws '<token> not recognized' for anything else. This is a completion-time error, not raised by normal exec (exec uses usageError instead).

Source

Thrown at deps/npm/lib/commands/access.js:68

    if (argv.length === 2) {
      return commands
    }

    if (argv.length === 3) {
      switch (argv[2]) {
        case 'grant':
          return ['read-only', 'read-write']
        case 'revoke':
          return []
        case 'list':
        case 'ls':
          return ['packages', 'collaborators']
        case 'get':
          return ['status']
        case 'set':
          return setCommands
        default:
          throw new Error(argv[2] + ' not recognized')
      }
    }
  }

  async exec ([cmd, subcmd, ...args]) {
    if (!cmd) {
      throw this.usageError()
    }
    if (!commands.includes(cmd)) {
      throw this.usageError(`${cmd} is not a valid access command`)
    }
    // All commands take at least one more parameter so we can do this check up front
    if (!subcmd) {
      throw this.usageError()
    }

    switch (cmd) {
      case 'grant':

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Use a valid access subcommand: grant, revoke, list (ls), get, or set
  2. Regenerate shell completion via `npm completion >> ~/.bashrc` (or zsh equivalent) to refresh the token list
  3. If calling completion programmatically, restrict the candidate token to the documented set
Defensive patterns

Strategy: validation

Validate before calling

const valid = ['grant', 'revoke', 'list', 'ls', 'get', 'set']
if (!valid.includes(token)) {
  // skip emitting the token in completion output
}

Type guard

function isAccessSubcommand(t) {
  return ['grant', 'revoke', 'list', 'ls', 'get', 'set'].includes(t)
}

Prevention

When it happens

Trigger: Triggering completion (npm access <TAB> or a custom completer) with a token that is not one of the recognized subcommands. Stale shell completion scripts that send an outdated token list can also surface it.

Common situations: Old bash/zsh completion cached from a previous npm version; a wrapper that calls npm completion programmatically with an invalid subcommand.

Related errors


AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13). Data as JSON: /api/errors/32eb1444da7ad981. Report an issue: GitHub.