npmrc token auth does not work on win7

What I Wanted to Do

I wanted to login to my npm account with token auth, so I added the token to my ~/.npmrc file.

What Happened Instead

After npm logout and restarting the git bash the npm whoami told me that I need to authenticate first (failed with 401). So apparently the npmrc did not login by starting the bash.

Reproduction Steps

  1. install win7 x64, git, git bash and npm
  2. login to npm, generate an auth token
  3. add the following to your ~/.npmrc file (the email and the shell path was auto generated)
    //registry.npmjs.org/:_authToken={token}
    email={email}
    shell=C:\Program Files\Git\bin\bash.exe
    
  4. start git bash
  5. type “npm whoami”

Platform Info

$ npm --versions
{ npm: '6.4.1',
  ares: '1.14.0',
  cldr: '33.1',
  http_parser: '2.8.0',
  icu: '62.1',
  modules: '64',
  napi: '3',
  nghttp2: '1.33.0',
  node: '10.11.0',
  openssl: '1.1.0i',
  tz: '2018e',
  unicode: '11.0',
  uv: '1.23.0',
  v8: '6.8.275.32-node.28',
  zlib: '1.2.11' }

$ node -p process.platform
win32

$ node --version
v10.11.0

Idk. what happened since yesterday, but it started to work today with the exact same code. I checked npmjs.com and it had zero tokens, so I created a new one, added to ~/.npmrc and successfully logged in by starting the bash. I think it’s worth to mention that npm logout destroys the token and removes the auth token line from the ~/.npmrc file. I did not remember using that command, the file did not change and I remember checking the token list every now and then on the site and I got the token there, so I don’t know why it did not work yesterday. I am glad it works today though, I hope it keeps that way.

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