npm Community Forum (Archive)

The npm community forum has been discontinued.

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

Cannot install packages with slashes if I use a .npmrc file - converts / to %2f

What I Wanted to Do

Install a package such as @zeit/next-sass

What Happened Instead

The install attempt fails with these messages:

npm install @zeit/next-sass
npm ERR! code E404
npm ERR! 404 Not Found - GET - Not Found
npm ERR! 404 
npm ERR! 404  '@zeit/next-sass@latest' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

Reproduction Steps

The above error only occurs if I have a .npmrc file. Put this line into the .npmrc file in your user’s root folder:

_auth = foo

The _auth attribute must be there to see the problem. I have this _auth typically because there are other registries in the list that require it, but I want it to default to the npmjs public registry if not one of my private ones. For simplicity I’ve removed the @other:registry= entries to give the smallest test case that shows the problem.

Now with the above .npmrc file in your root folder (eg ~/.npmrc) go to a new/empty folder and run this command:
npm install @zeit/next-sass

You should get the above error messages.


When run without any .npmrc file present it works.
When run with a .npmrc file that doesn’t contain an _auth value, it also works.

The problem seems to be that in the case of an _auth being present, the slash that is part of the package name is being encoded to %2f when it should not, making npm fail to locate it in the repository.

Platform Info

$ npm --versions
{ npm: '6.11.3',
  ares: '1.15.0',
  brotli: '1.0.7',
  cldr: '35.1',
  http_parser: '2.8.0',
  icu: '64.2',
  modules: '64',
  napi: '4',
  nghttp2: '1.34.0',
  node: '10.16.0',
  openssl: '1.1.1b',
  tz: '2019a',
  unicode: '12.1',
  uv: '1.28.0',
  v8: '',
  zlib: '1.2.11' }

$ node -p process.platform