7

I'm having this problem when I issue an npm command I get a message that it is unable to authenticate with the npm registry (hosted in Azure DevOps) and I suspect that it might be because it is not generating an authorization header and sending it along with the request.

For example, when I issue these commands: npm ping or npm install, it gives this complaint.

npm ERR! code E401
npm ERR! Unable to authenticate, your authentication token seems to be invalid.
npm ERR! To correct this please trying logging in again with:
npm ERR!     npm login

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\blah\AppData\Roaming\npm-cache\_logs\2020-01-15T06_30_45_484Z-debug.log

I have a different npm registry (hosted under a different Azure DevOps instance) that works when I issue these commands and upon looking at the requests under Fiddler, I noticed that the working request has the authorization header contain the username and password to access the registry, however, the non-working request (to the non-working registry) does not have it.

Besides the registry url,username, and password in the npmrc file, they are pretty much the same as shown here:

registry=https://devops.blah/npm/registry/
always-auth=true
strict-ssl=false
; Treat this auth token like a password. Do not share it with anyone, including Microsoft support. This token expires on or before 02/03/2020.
; begin auth token
//devops.blah/npm/registry/:username=blah
//devops.blah/npm/registry/:_password=blahpassword
//devops.blah/npm/registry/:email=npm requires email to be set but doesn't use the value
//devops.blah/npm/:username=blah
//devops.blah/npm/:_password=blahpassword
//devops.blah/npm/:email=npm requires email to be set but doesn't use the value
; end auth token

The npm command was issued on the same machine and in the same command prompt session (I switch to the relevant npmrc profile when I do so).

What could cause the npm command to not include the Authorization Header in its request to the non-working registry?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.