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
value
$ 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: '6.8.275.32-node.45',
  zlib: '1.2.11' }
$ node -p process.platform
darwin

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
false
$ npm config set always-auth
$ npm config get always-auth
true

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