{"record":{"id":"f7d9582b0fc0543f","repo":"nodejs/node","slug":"unknown-profile-command-subcmd","errorCode":null,"errorMessage":"Unknown profile command: ${subcmd}","messagePattern":"Unknown profile command: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"deps/npm/lib/commands/profile.js","lineNumber":98,"sourceCode":"    const [subcmd, ...opts] = args\n\n    switch (subcmd) {\n      case 'enable-2fa':\n      case 'enable-tfa':\n      case 'enable2fa':\n      case 'enabletfa':\n        return this.enable2fa(opts)\n      case 'disable-2fa':\n      case 'disable-tfa':\n      case 'disable2fa':\n      case 'disabletfa':\n        return this.disable2fa()\n      case 'get':\n        return this.get(opts)\n      case 'set':\n        return this.set(opts)\n      default:\n        throw new Error('Unknown profile command: ' + subcmd)\n    }\n  }\n\n  async get (args) {\n    const tfa = 'two-factor auth'\n    const info = await get({ ...this.npm.flatOptions })\n\n    if (!info.cidr_whitelist) {\n      delete info.cidr_whitelist\n    }\n\n    if (this.npm.config.get('json')) {\n      output.buffer(info)\n      return\n    }\n\n    // clean up and format key/values for output\n    const cleaned = {}","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/npm/lib/commands/profile.js#L80-L116","documentation":"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.","triggerScenarios":"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.","commonSituations":"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').","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"],"exampleFix":"// before\nnpm profile update\n\n// after\nnpm profile set","handlingStrategy":"validation","validationCode":"const VALID_PROFILE_CMDS = ['enable-2fa', 'enable2fa', 'enable-tfa', 'enabletfa', 'disable-2fa', 'disable2fa', 'disable-tfa', 'disabletfa', 'get', 'set']\nfunction isValidProfileCmd(cmd) {\n  return VALID_PROFILE_CMDS.includes(cmd)\n}\n// Before invoking:\nif (!isValidProfileCmd(subcmd)) {\n  console.error(`Valid commands: get, set, enable-2fa, disable-2fa`)\n}","typeGuard":"function isProfileCommand(cmd) {\n  return typeof cmd === 'string'\n    && ['enable-2fa', 'enable2fa', 'enable-tfa', 'enabletfa',\n        'disable-2fa', 'disable2fa', 'disable-tfa', 'disabletfa',\n        'get', 'set'].includes(cmd)\n}","tryCatchPattern":"try {\n  await exec([subcmd, ...opts])\n} catch (e) {\n  if (e.message.includes('Unknown profile command')) {\n    console.error('Valid: enable-2fa, disable-2fa, get, set')\n  }\n  throw e\n}","preventionTips":["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"],"tags":["npm","profile","argument-validation","cli"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}