npm install from tfs feed (on build process) give error: Unable to authenticate
Solution 1
- Install this in machine:
npm install -g vsts-npm-auth
- Run this (in the directory where npmrc file is):
vsts-npm-auth -config .npmrc
Solution 2
Create a file .npmrc
in your project folder and add the following
registry=Your URL
always-auth=true
In the command prompt run both of these commands
npm install -g vsts-npm-auth --registry https://registry.npmjs.com --always-auth false
vsts-npm-auth -config .npmrc
banana
Updated on June 23, 2022Comments
-
banana almost 2 years
We have our own npm package and a project that uses it, I want to publish it to a tfs feed - repository and install it from there instead of from a physical file.
I published the package to the feed from my development machine,
and I changed the reference within the project that consumes it.The whole process works fine from my machine, but when I try to consume the package on a build process in the tfs - it fails with the error :
Unable to authenticate, your authentication token seems to be invalid.
I've created
.npmrc
file at the project level with the registry address, and another file with credentials on the user directory, and I did the same on the TFS machine.What can cause the npm install (from my feed) to not work on the tfs machine?
EDIT:
When I add prefix @my to the registry at the user-level .npmrc file - like this:@my:registry=https://my-feed-address
The error changes to: "No valid versions available for my-package"
-
Leo BL almost 5 yearsi had the same problem but this solved in my case. in my build pipeline everytime before the restore i execute this vsts-npm-auth -config .npmrc. it works directly in build machine (without build process)? have you tried?
-
Ivan P about 4 yearsThat's only works on Windows according to DevOps' documentation.
-
ntg almost 3 yearsDoes NOT work for ubuntu:
cannot execute binary file: Exec format error
... possibly this is only for Windows OS -
ntg over 2 yearsFor Windows this did it for me.... You have to enable the script polycies (e.g.
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted
Yes )