[BUG] npm 7 + Azure Devops Artifacts
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.1k
- Forks
- 4.7k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 19
Description
We have an issue very similar to this bug report https://github.com/npm/cli/issues/2183, which has apparently been fixed. However we're seeing the issue in the latest version of v7 (and previous versions).
Current Behavior:
We have a number of Azure Devops build pipelines which make use of the built in Artifacts (registry) feature. All build pipelines are already authenticated to retrieve these packages, and it works fine with v6.
The build pipelines utilise the npm task (https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/package/npm?view=azure-devops) to perform the install. However the install task is failing with 401 errors.
An odd thing I have noticed in the logs is that the pipeline runs a npm config list and the results are different between using v6 and v7:
v6
SYSTEMVSSCONNECTION exists true
SYSTEMVSSCONNECTION exists true
/opt/hostedtoolcache/node/14.15.4/x64/bin/npm --version
6.14.11
SYSTEMVSSCONNECTION exists true
SYSTEMVSSCONNECTION exists true
/opt/hostedtoolcache/node/14.15.4/x64/bin/npm config list
; cli configs
metrics-registry = "https://***.pkgs.visualstudio.com/_packaging/***-***-***-***-***/npm/registry/"
scope = ""
user-agent = "npm/6.14.11 node/v14.15.4 linux x64"
; environment configs
userconfig = "/home/vsts/work/1/npm/956552.npmrc"
; userconfig /home/vsts/work/1/npm/956552.npmrc
registry = "https://***.pkgs.visualstudio.com/_packaging/***-***-***-***-***/npm/registry/"
; node bin location = /opt/hostedtoolcache/node/14.15.4/x64/bin/node
; cwd = /path/to/App
; HOME = /home/vsts
; "npm config ls -l" to show all defaults.
/opt/hostedtoolcache/node/14.15.4/x64/bin/npm ci
v7
SYSTEMVSSCONNECTION exists true
SYSTEMVSSCONNECTION exists true
/opt/hostedtoolcache/node/14.15.4/x64/bin/npm --version
7.5.2
SYSTEMVSSCONNECTION exists true
SYSTEMVSSCONNECTION exists true
/opt/hostedtoolcache/node/14.15.4/x64/bin/npm config list
; "user" config from /home/vsts/work/1/npm/956544.npmrc
//***.pkgs.visualstudio.com/_packaging/***-***-***-***-***/npm/registry/:_authToken = (protected)
registry = "https://***.pkgs.visualstudio.com/_packaging/***-***-***-***-***/npm/registry/"
; "env" config from environment
userconfig = "/home/vsts/work/1/npm/956544.npmrc"
; "cli" config from command line options
omit = []
user-agent = "npm/7.5.2 node/v14.15.4 linux x64 ci/azure-pipelines"
; node bin location = /opt/hostedtoolcache/node/14.15.4/x64/bin/node
; cwd = /path/to/App
; HOME = /home/vsts
; Run `npm config ls -l` to show all defaults.
/opt/hostedtoolcache/node/14.15.4/x64/bin/npm ci
As you can see, v7 shows this in the config //***.pkgs.visualstudio.com/_packaging/***-***-***-***-***/npm/registry/:_authToken = (protected) , which v6 doesn't. And the install error log is around an invalid auth token. So not sure if this has something to do with it.
Install log Error:
4097 timing command:ci Completed in 22670ms
4098 verbose stack Error: Unable to authenticate, need: Bearer authorization_uri=https://login.windows.net/***-***-***-***-***, Basic realm="https://pkgsprodsu3weu.app.pkgs.visualstudio.com/", TFS-Federated
4098 verbose stack at /opt/hostedtoolcache/node/14.15.4/x64/lib/node_modules/npm/node_modules/npm-registry-fetch/check-response.js:113:17
4098 verbose stack at processTicksAndRejections (internal/process/task_queues.js:93:5)
4099 verbose statusCode 401
4100 verbose pkgid yargs-parser@https://pkgs.dev.azure.com/****/_packaging/***/npm/registry/yargs-parser/-/yargs-parser-13.1.2.tgz
4101 verbose cwd /path/to/App
4102 verbose Linux 5.4.0-1036-azure
4103 verbose argv "/opt/hostedtoolcache/node/14.15.4/x64/bin/node" "/opt/hostedtoolcache/node/14.15.4/x64/bin/npm" "ci"
4104 verbose node v14.15.4
4105 verbose npm v7.5.2
4106 error code E401
4107 error Unable to authenticate, your authentication token seems to be invalid.
4108 error To correct this please trying logging in again with:
4108 error npm login
4109 verbose exit 1
Expected Behavior:
The install process should work as v6 does.
Environment:
Azure Devops
npm task
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the Azure DevOps npm task with npm 7, comparing npm config list and npm ci against npm 6. Start with the authentication configuration shown in the issue and the failure location npm-registry-fetch/check-response.js. Done means authenticated Azure Artifacts installs succeed under npm 7 without the 401 error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, javascript, nodejs
- Domain
- cli, cloud, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100