nodejs/node · error · Error
Unknown profile command: ${subcmd}
Error message
Unknown profile command: ${subcmd} What it means
Thrown by the `profile` command's exec method when the first positional argument (subcommand) does not match any known profile subcommand. Recognized subcommands include both hyphenated and camelCase variants: enable-2fa/enable2fa/enable-tfa/enabletfa, disable-2fa/disable2fa/disable-tfa/disabletfa, get, and set.
Source
Thrown at deps/npm/lib/commands/profile.js:98
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':
case 'disable2fa':
case 'disabletfa':
return this.disable2fa()
case 'get':
return this.get(opts)
case 'set':
return this.set(opts)
default:
throw new Error('Unknown profile command: ' + subcmd)
}
}
async get (args) {
const tfa = 'two-factor auth'
const info = await get({ ...this.npm.flatOptions })
if (!info.cidr_whitelist) {
delete info.cidr_whitelist
}
if (this.npm.config.get('json')) {
output.buffer(info)
return
}
// clean up and format key/values for output
const cleaned = {}View on GitHub (pinned to 1b2de5e052)
Solutions
- Check valid subcommands with `npm profile --help`
- Use one of: enable-2fa, disable-2fa, get, or set
- Ensure you are on a current npm version that supports the subcommand you expect
Example fix
// before npm profile update // after npm profile set
Defensive patterns
Strategy: validation
Validate before calling
const VALID_PROFILE_CMDS = ['enable-2fa', 'enable2fa', 'enable-tfa', 'enabletfa', 'disable-2fa', 'disable2fa', 'disable-tfa', 'disabletfa', 'get', 'set']
function isValidProfileCmd(cmd) {
return VALID_PROFILE_CMDS.includes(cmd)
}
// Before invoking:
if (!isValidProfileCmd(subcmd)) {
console.error(`Valid commands: get, set, enable-2fa, disable-2fa`)
} Type guard
function isProfileCommand(cmd) {
return typeof cmd === 'string'
&& ['enable-2fa', 'enable2fa', 'enable-tfa', 'enabletfa',
'disable-2fa', 'disable2fa', 'disable-tfa', 'disabletfa',
'get', 'set'].includes(cmd)
} Try / catch
try {
await exec([subcmd, ...opts])
} catch (e) {
if (e.message.includes('Unknown profile command')) {
console.error('Valid: enable-2fa, disable-2fa, get, set')
}
throw e
} Prevention
- Check valid subcommands with npm profile --help before running
- Both hyphenated (enable-2fa) and camelCase (enable2fa) variants are accepted
- Do not assume subcommands from other CLIs exist in npm profile
When it happens
Trigger: Running `npm profile <unknown>` where the subcommand is not in the recognized list. For example `npm profile update` or `npm profile delete`. The exec switches on `subcmd` and hits the default case.
Common situations: Misspelling a subcommand, using a subcommand from an older or newer npm version, or assuming a subcommand exists that doesn't (e.g., 'profile create', 'profile login').
Related errors
- npm profile set <prop> <value>
- "${prop}" is not a property we can set. Valid properties are
- First argument `orgname` is required.
- Second argument `username` is required.
- Third argument `role` must be one of `owner`, `admin`, or `d
AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13).
Data as JSON: /api/errors/f7d9582b0fc0543f.
Report an issue: GitHub.