nodejs/node · info · Error
${argv[2]} not recognized
Error message
${argv[2]} not recognized What it means
Thrown by the npm `profile` command's shell-completion handler when the subcommand word at argv[2] does not match any recognized value: enable-2fa, enable-tfa, disable-2fa, disable-tfa, get, set. The completion function returns suggestion arrays for known subcommands and throws for anything else. This fires during tab-completion only.
Source
Thrown at deps/npm/lib/commands/profile.js:71
static async completion (opts) {
var argv = opts.conf.argv.remain
if (!argv[2]) {
return ['enable-2fa', 'disable-2fa', 'get', 'set']
}
switch (argv[2]) {
case 'enable-2fa':
case 'enable-tfa':
return ['auth-and-writes', 'auth-only']
case 'disable-2fa':
case 'disable-tfa':
case 'get':
case 'set':
return []
default:
throw new Error(argv[2] + ' not recognized')
}
}
async exec (args) {
if (args.length === 0) {
throw this.usageError()
}
const [subcmd, ...opts] = args
switch (subcmd) {
case 'enable-2fa':
case 'enable-tfa':
case 'enable2fa':
case 'enabletfa':
return this.enable2fa(opts)
case 'disable-2fa':
case 'disable-tfa':View on GitHub (pinned to 1b2de5e052)
Solutions
- Regenerate completions: `npm completion >> ~/.bashrc` then `source ~/.bashrc`
- Verify you are tab-completing a valid subcommand: enable-2fa, disable-2fa, get, or set
- Update npm: `npm install -g npm@latest` and refresh completions
Example fix
// No code fix — shell-completion path only // User fix: // npm completion >> ~/.bashrc && source ~/.bashrc
Defensive patterns
Strategy: validation
Validate before calling
const VALID_PROFILE_SUBCOMMANDS = ['enable-2fa', 'enable-tfa', 'disable-2fa', 'disable-tfa', 'get', 'set']
function isValidProfileSubcommand(cmd) {
return VALID_PROFILE_SUBCOMMANDS.includes(cmd)
} Type guard
function isProfileSubcommand(cmd) {
return typeof cmd === 'string'
&& ['enable-2fa', 'enable-tfa', 'disable-2fa', 'disable-tfa', 'get', 'set'].includes(cmd)
} Prevention
- Regenerate completions after npm upgrades: `npm completion >> ~/.bashrc`
- Keep npm updated so completion scripts match the installed version
- When scripting, validate subcommands against the known list
When it happens
Trigger: Triggered when the shell invokes npm's completion machinery and the word at position argv[2] is not a recognized profile subcommand. For example, tab-completing `npm profile foo<TAB>` passes a non-matching fragment into the default case.
Common situations: Stale shell completion cache after an npm upgrade. A misconfigured bash/zsh completion script. Typing an unknown subcommand prefix during tab-completion.
Related errors
- ${argv[2]} not recognized
- Unknown profile command: ${subcmd}
- npm profile set <prop> <value>
- npm profile set password Do not include your current or new
- "${prop}" is not a property we can set. Valid properties are
AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13).
Data as JSON: /api/errors/de9934bbc76f2e82.
Report an issue: GitHub.