nodejs/node · warning · Error
${argv[2]} not recognized
Error message
${argv[2]} not recognized What it means
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.
Source
Thrown at deps/npm/lib/commands/token.js:48
'bypass-2fa',
'password',
'registry',
'otp',
'read-only',
]
static async completion (opts) {
const argv = opts.conf.argv.remain
const subcommands = ['list', 'revoke', 'create']
if (argv.length === 2) {
return subcommands
}
if (subcommands.includes(argv[2])) {
return []
}
throw new Error(argv[2] + ' not recognized')
}
async exec (args) {
if (args.length === 0) {
return this.list()
}
switch (args[0]) {
case 'list':
case 'ls':
return this.list()
case 'rm':
case 'delete':
case 'revoke':
case 'remove':
return this.rm(args.slice(1))
case 'create':
return this.create(args.slice(1))
default:View on GitHub (pinned to 1b2de5e052)
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.
Example fix
// before npm token delete <TAB> // after npm token revoke <TAB>
Defensive patterns
Strategy: validation
Validate before calling
const TOKEN_SUBCOMMANDS = ['list', 'revoke', 'create']
function normalizeTokenCmd(cmd) {
// runtime aliases accepted by exec
if (cmd === 'ls') return 'list'
if (cmd === 'rm' || cmd === 'delete') return 'revoke'
return cmd
}
function assertTokenSubcommand(cmd) {
if (!['list', 'revoke', 'create', 'ls', 'rm', 'delete'].includes(cmd)) {
throw new Error(`Unknown npm token subcommand "${cmd}"`)
}
} Type guard
function isTokenSubcommand(cmd) {
return ['list', 'revoke', 'create', 'ls', 'rm', 'delete'].includes(cmd)
} Prevention
- 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.
When it happens
Trigger: Completion invoked with `argv.length > 2` and `argv[2]` not in `['list','revoke','create']` (e.g. tab-completing `npm token del`).
Common situations: 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`.
Related errors
- ${argv[2]} not recognized
- `npm rebuild` only supports SemVer version/range specifiers
- Missing script: "${event}"${suggestions} To see a list of s
- search must be called with arguments
- Token ID "${id}" was ambiguous, a new token may have been cr
AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13).
Data as JSON: /api/errors/9e55c02640bcba49.
Report an issue: GitHub.