1
votes

I tried setting an environment variable (NPM_TOKEN) for VSTS on the variables tab / Process variables but it looks like the build process tool (NPM) doesn't recognize it.

I also tried to run a command line task echo $NPM_TOKEN which also fails:

Failed which: Not found echo $NPM_TOKEN: null

I tried using a Hosted Agent as well as a Hosted Linux (Preview) agent.

1

1 Answers

1
votes

The variable can be recognized both for build and release. And you should use the variable as the format $(NPM_TOKEN).

For Command Line task:

enter image description here

For PowerShell task:

enter image description here


Add .nmprc via web UI:

Open your project -> code -> make sure the git repo and branch is what your want to add file -> New file -> file name is .npmrc -> copy the token as content -> commit.

enter image description here