{"record":{"id":"67bc4ff494b13735","repo":"nodejs/node","slug":"basekey-is-not-a-valid-npm-option","errorCode":null,"errorMessage":"`${baseKey}` is not a valid npm option","messagePattern":"`(.+?)` is not a valid npm option","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"deps/npm/lib/commands/config.js","lineNumber":170,"sourceCode":"      case 'fix':\n        await this.fix()\n        break\n      default:\n        throw this.usageError()\n    }\n  }\n\n  async set (args) {\n    if (!args.length) {\n      throw this.usageError()\n    }\n\n    const where = this.npm.flatOptions.location\n    for (const [key, val] of Object.entries(keyValues(args))) {\n      log.info('config', 'set %j %j', key, val)\n      const baseKey = key.split(':').pop()\n      if (!this.npm.config.definitions[baseKey] && !nerfDarts.includes(baseKey)) {\n        throw new Error(`\\`${baseKey}\\` is not a valid npm option`)\n      }\n      const deprecated = this.npm.config.definitions[baseKey]?.deprecated\n      if (deprecated) {\n        throw new Error(\n          `The \\`${baseKey}\\` option is deprecated, and cannot be set in this way${deprecated}`\n        )\n      }\n\n      if (val === '') {\n        this.npm.config.delete(key, where)\n      } else {\n        this.npm.config.set(key, val, where)\n      }\n\n      if (!this.npm.config.validate(where)) {\n        log.warn('config', 'omitting invalid config values')\n      }\n    }","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/npm/lib/commands/config.js#L152-L188","documentation":"`npm config set <key> <val>` checks each key against npm's config definitions (and the nerf-dart auth-key allowlist). A key whose base segment (after the last ':') is neither a known option nor a nerf-dart is rejected as invalid, preventing silent typos that would otherwise write junk into .npmrc.","triggerScenarios":"Typo'd option name, an option removed in this npm version, or a key that is neither a defined config option nor an auth-scoped nerf-dart like //registry.example.org/:_authToken.","commonSituations":"Following an outdated blog post with a renamed/removed option; misspelling (e.g. 'regsitry'); CI that writes dynamic keys.","solutions":["Check the canonical list with `npm config list -l` or `npm help config` and use the exact key","Fix the typo in the key name","For registry-scoped auth, use the nerf-dart form (//<registry>/:_authToken) which is allowed"],"exampleFix":"# before\nnpm config set regsitry https://registry.npmjs.org\n\n# after\nnpm config set registry https://registry.npmjs.org","handlingStrategy":"validation","validationCode":"const npm = require('npm/package.json') // or your npm instance's config\nconst definitions = require('@npmcli/config/lib/definitions/index.js').definitions // path may vary\nconst nerfDarts = [] // nerf-dart keys are dynamic\nfunction isValidConfigKey(key) {\n  const base = key.split(':').pop()\n  return Boolean(definitions[base]) || /^\\/\\/.+\\//:/./.test(key) || nerfDarts.includes(base)\n}","typeGuard":"function isKnownNpmOption(key, definitions) {\n  return Object.prototype.hasOwnProperty.call(definitions, key.split(':').pop())\n}","tryCatchPattern":null,"preventionTips":["Cross-check keys against `npm config list -l` before scripting them","Treat typos as fatal in provisioning scripts (fail fast)","Use nerf-dart form for auth keys"],"tags":["config","cli","validation","npmrc"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}