npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

Using npm config set registry [url] doesn't update project .npmrc file.

What I Wanted to Do

During my CI build process I want to swap what registry I use so that I am pulling from a controlled set of packages (no potential for other packages to be downloaded). So in my build, based on some pre-condition (e.g. what branch I am building on), I call npm config set registry [url]. I expected the project local .npmrc file to be updated.

What Happened Instead

Nothing. The command appears to have returned successfully but the contents of the project local .npmrc file weren’t updated with the registry value, nor was any other configuration file. If I issue a npm config list command I can confirm the values didn’t stick anywhere.

Reproduction Steps

Create a local .npmrc file in a project with a registry setting. Invoke npm config list to confirm these values are being used.

Now invoke npm config set registry https://foo followed by npm config list. Observe that the value wasn’t updated.


I worked around this by just doing an echo registry=[url]>.npmrc in a script and that does the trick. No idea why the command isn’t working but I think it should.

Platform Info

$ npm --versions
C:\Code\pwned>npm --versions
{ mymodule: '1.0.0',
  npm: '6.5.0-next.0',
  ares: '1.15.0',
  cldr: '34.0',
  http_parser: '2.8.0',
  icu: '63.1',
  llhttp: '1.0.1',
  modules: '67',
  napi: '3',
  nghttp2: '1.34.0',
  node: '11.6.0',
  openssl: '1.1.0j',
  tz: '2018e',
  unicode: '11.0',
  uv: '1.24.1',
  v8: '',
  zlib: '1.2.11' }
$ node -p process.platform