nodejs/node · error · Error

npm profile set <prop> <value>

Error message

npm profile set <prop> <value>

What it means

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.

Source

Thrown at deps/npm/lib/commands/profile.js:180

    const conf = { ...this.npm.flatOptions }
    const prop = (args[0] || '').toLowerCase().trim()

    let value = args.length > 1 ? args.slice(1).join(' ') : null

    const readPasswords = async () => {
      const newpassword = await readUserInfo.password('New password: ')
      const confirmedpassword = await readUserInfo.password('       Again:     ')

      if (newpassword !== confirmedpassword) {
        log.warn('profile', 'Passwords do not match, please try again.')
        return readPasswords()
      }

      return newpassword
    }

    if (prop !== 'password' && value === null) {
      throw new Error('npm profile set <prop> <value>')
    }

    if (prop === 'password' && value !== null) {
      throw new Error(
        'npm profile set password\n' +
        'Do not include your current or new passwords on the command line.')
    }

    if (writableProfileKeys.indexOf(prop) === -1) {
      throw new Error(`"${prop}" is not a property we can set. ` +
        `Valid properties are: ` + writableProfileKeys.join(', '))
    }

    if (prop === 'password') {
      const current = await readUserInfo.password('Current password: ')
      const newpassword = await readPasswords()

      value = { old: current, new: newpassword }

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Provide both property and value: `npm profile set <prop> <value>`
  2. For password changes, use `npm profile set password` and follow interactive prompts
  3. Check writable properties with `npm profile set --help`

Example fix

// before
npm profile set email

// after
npm profile set email me@example.com
Defensive patterns

Strategy: validation

Validate before calling

function validateProfileSetArgs(prop, value) {
  if (prop !== 'password' && value == null) {
    throw new Error('A value is required for non-password properties')
  }
}

Type guard

function hasProfileSetValue(prop, value) {
  return prop === 'password' || (value !== null && value !== undefined)
}

Try / catch

try {
  await exec(['set', prop, value])
} catch (e) {
  if (e.message.includes('npm profile set')) {
    console.error('Usage: npm profile set <prop> <value>')
  }
  throw e
}

Prevention

When it happens

Trigger: Running `npm profile set <prop>` with only one argument where prop is not 'password'. The code checks `if (prop !== 'password' && value === null)` and throws.

Common situations: 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.

Related errors


AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13). Data as JSON: /api/errors/795650f733918d4c. Report an issue: GitHub.