I'm trying to connect to a Azure DevOps Artifacts feed, but I keep getting an E401 error.
I've tried on a different computer and it connected just fine. I've uninstalled, and reinstalled my Node.js, and I still got the error.
Below is the error I get when I run 'npm install'
npm ERR! code E401 npm ERR! Unable to authenticate, need: Bearer authorization_uri=https://login.windows.net/*********, Basic realm="https://pkgsprodcus1.pkgs.visualstudio.com/", TFS-Federated
Below is what was added to the .npmrc file
registry=https://[org].pkgs.visualstudio.com/_packaging/[feed].Npm/npm/registry //pkgs.dev.azure.com/[org]/_packaging/[feed].Npm/npm/registry/:_authToken=[token] //pkgs.dev.azure.com/[org]/_packaging/[feed].Npm/npm/:_authToken=[token]
I expected to be connected to the feed after adding my info to the .npmrc file, and running 'npm install'
Example: to run npm run myTask -- --users='{"foo":"bar"}' , provide this input: run myTask -- --users="{"foo":"bar"}" . You can either commit a . npmrc file to your source code repository and set its path or select a registry from Azure Artifacts. Select this option to use feeds specified in a .
Solution #1: manually refresh the token Maybe your token is simply expired. You can simply navigate to Azure DevOps and generate new credentials to be stored in the . npmrc file at user level.
I had an issue where I couldn't connect, even though I had the same .npmrc as other repos on the same machine. Running vsts-npm-auth -config .npmrc
just exited, presumably happy with the cached credentials.
However, the credentials it had seemed to be bad. The solution was to force refreshing the token: vsts-npm-auth -config .npmrc -force
This usually happens when you've recently changed your password. To fix this problem, I ran this command within VS Code's Powershell terminal (any terminal will work)
vsts-npm-auth -config .npmrc
With doing so, a GUI popped-up where I was able to select the account I wanted to use to authenticate.
I hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With