Documentation and behaviour inconsistent for "npm config set key" with omitted value

The web documentation for npm config set and command-line npm help config says:

npm config set key value
Sets the config key to the value.
If value is omitted, then it sets it to “true”.

But the last line is not correct, the value is left empty. Tried with npm@2 npm@3 npm@4 npm@5 npm@6

Reproduction Steps

$ npm config set key value
$ npm config get key
$ npm config set key 
$ npm config get key


Platform Info

$ npm --versions
{ demo: '1.0.0',
  npm: '6.7.0',
  ares: '1.15.0',
  cldr: '33.1',
  http_parser: '2.8.0',
  icu: '62.1',
  modules: '64',
  napi: '3',
  nghttp2: '1.34.0',
  node: '10.15.0',
  openssl: '1.1.0j',
  tz: '2018e',
  unicode: '11.0',
  uv: '1.23.2',
  v8: '',
  zlib: '1.2.11' }
$ node -p process.platform

I believe that only works if the flag is known to be a Boolean flag (see below). That could be documented better though.

1 Like

Oh, right.

$ npm config get always-auth
$ npm config set always-auth
$ npm config get always-auth

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.