npm unable to authenticate

This week I tried to run a npm install command and update all the packages in a React appliction. The problem is that I haven’t touched this project in weeks if not months. During this time the npm credentials token seems to have expired and my npm intall failed and produced the following error.

Unable to authenticate, need: Bearer authorization_uri=https://login.windows.net/d950fde8-c220-47ba-953e-5912a9148c31, Basic realm="https://pkgsprodsu3weu.app.pkgs.visualstudio.com/"

What worked for me was running the following command

vsts-npm-auth -config .npmrc

Just in case you get this error,

'vsts-npm-auth' is not recognized as an internal or external command, operable program or batch file.

Then just run this package install command,

npm install -g vsts-npm-auth

Now that I had my credentials token update I was able to run npm install again without any issues.

UPDATE:
If the issue persists try running this

vsts-npm-auth -config .npmrc -r -f -v normal

Until next post,
Bjorn

Leave a comment