{"record":{"id":"795650f733918d4c","repo":"nodejs/node","slug":"npm-profile-set-prop-value","errorCode":null,"errorMessage":"npm profile set <prop> <value>","messagePattern":"npm profile set <prop> <value>","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"deps/npm/lib/commands/profile.js","lineNumber":180,"sourceCode":"    const conf = { ...this.npm.flatOptions }\n    const prop = (args[0] || '').toLowerCase().trim()\n\n    let value = args.length > 1 ? args.slice(1).join(' ') : null\n\n    const readPasswords = async () => {\n      const newpassword = await readUserInfo.password('New password: ')\n      const confirmedpassword = await readUserInfo.password('       Again:     ')\n\n      if (newpassword !== confirmedpassword) {\n        log.warn('profile', 'Passwords do not match, please try again.')\n        return readPasswords()\n      }\n\n      return newpassword\n    }\n\n    if (prop !== 'password' && value === null) {\n      throw new Error('npm profile set <prop> <value>')\n    }\n\n    if (prop === 'password' && value !== null) {\n      throw new Error(\n        'npm profile set password\\n' +\n        'Do not include your current or new passwords on the command line.')\n    }\n\n    if (writableProfileKeys.indexOf(prop) === -1) {\n      throw new Error(`\"${prop}\" is not a property we can set. ` +\n        `Valid properties are: ` + writableProfileKeys.join(', '))\n    }\n\n    if (prop === 'password') {\n      const current = await readUserInfo.password('Current password: ')\n      const newpassword = await readPasswords()\n\n      value = { old: current, new: newpassword }","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/npm/lib/commands/profile.js#L162-L198","documentation":"Thrown by the `profile set` method when the property being set is not 'password' but no value was provided. For non-password properties, a value is mandatory. The value being null means the user ran `npm profile set <prop>` without a second argument. Password is handled specially — it prompts interactively.","triggerScenarios":"Running `npm profile set <prop>` with only one argument where prop is not 'password'. The code checks `if (prop !== 'password' && value === null)` and throws.","commonSituations":"Forgetting to include the value: `npm profile set email` instead of `npm profile set email me@example.com`. Scripting the command without providing both arguments.","solutions":["Provide both property and value: `npm profile set <prop> <value>`","For password changes, use `npm profile set password` and follow interactive prompts","Check writable properties with `npm profile set --help`"],"exampleFix":"// before\nnpm profile set email\n\n// after\nnpm profile set email me@example.com","handlingStrategy":"validation","validationCode":"function validateProfileSetArgs(prop, value) {\n  if (prop !== 'password' && value == null) {\n    throw new Error('A value is required for non-password properties')\n  }\n}","typeGuard":"function hasProfileSetValue(prop, value) {\n  return prop === 'password' || (value !== null && value !== undefined)\n}","tryCatchPattern":"try {\n  await exec(['set', prop, value])\n} catch (e) {\n  if (e.message.includes('npm profile set')) {\n    console.error('Usage: npm profile set <prop> <value>')\n  }\n  throw e\n}","preventionTips":["Always provide both property and value for non-password properties","For password changes, use npm profile set password with no value (interactive)","Check writable properties with npm profile set --help"],"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"}