6

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"

15
  • The build agent run with user, give to this user permissions in the feed. Commented Jun 30, 2019 at 13:39
  • @ShaykiAbramczyk, Do you mean Feed settings->Permissions ? If so, this user has owner permission. Commented Jul 1, 2019 at 4:09
  • Can you share your build pipeline? Commented Jul 1, 2019 at 5:57
  • @ShaykiAbramczyk, I do not think that's the point, Because even when I run the npm install command in the tfs server - in the project folder within the relevant 's' folder - I get the same behavior. + I edited my question. Commented Jul 2, 2019 at 5:03
  • Which version of TFS is it? Are you using the npm install task? it has and authentication section that you can point to your .npmrc file. There is also a npm authenticate task you might want to run first. Commented Jul 4, 2019 at 15:45

2 Answers 2

8
  1. Install this in machine: npm install -g vsts-npm-auth
  2. Run this (in the directory where npmrc file is): vsts-npm-auth -config .npmrc
Sign up to request clarification or add additional context in comments.

1 Comment

i 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?
4

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

3 Comments

That's only works on Windows according to DevOps' documentation.
Does NOT work for ubuntu: cannot execute binary file: Exec format error... possibly this is only for Windows OS
For Windows this did it for me.... You have to enable the script polycies (e.g. Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted Yes )

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.