404 error when trying to pull from Artifactory 5.4.6 NPM repo with NPM or higher if anonymous access is disabled

What I Wanted to Do

If I do an npm install with NPM 4.2.0 or lower, I’m able to install an Artifactory repo succesfully if that repo has anonymous access disabled.

If I try the same thing with NPM 5.0.0 or higher, I expect the same to happen.

What Happened Instead

I’m unable to install the repo and get a 404 error. For some NPM versions, I also get a 304 error.

Here’s the log when try this with NPM 5.6.0, on a Linux machine :

0 info it worked if it ends with ok
1 verbose cli [ '/home/release/nodejs/node-v8.11.1-linux-x64/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'install' ]
2 info using npm@5.6.0
3 info using node@v8.11.1
4 verbose npm-session 63d1960eac6e1e9a
5 silly install runPreinstallTopLevelLifecycles
6 silly preinstall release
7 info lifecycle @~preinstall: @
8 silly install loadCurrentTree
9 silly install readLocalPackageData
10 silly install loadIdealTree
11 silly install cloneCurrentTreeToIdealTree
12 silly install loadShrinkwrap
13 silly install loadAllDepsIntoIdealTree
14 http fetch GET 200 https://[DOMAIN]/artifactory/api/npm/product_release_npm/@luciad%2fria-core 334ms
15 http fetch GET 404 https://[DOMAIN]:443/artifactory/api/npm/product_release_npm/@luciad/ria-core/-/@luciad/ria-core-2019.0.1.tgz 32ms
16 silly fetchPackageMetaData error for @luciad/ria-core@^2019.0 404 Not Found: @luciad/ria-core@^2019.0
17 http fetch GET 404 https://[DOMAIN]:443/artifactory/api/npm/product_release_npm/@luciad/ria-core/-/@luciad/ria-core-2019.0.1.tgz 9ms
18 silly fetchPackageMetaData error for @luciad/ria-core@^2019.0 404 Not Found: @luciad/ria-core@^2019.0
19 silly saveTree release
20 verbose stack Error: 404 Not Found: @luciad/ria-core@^2019.0
20 verbose stack     at fetch.then.res (/home/release/nodejs/node-v8.11.1-linux-x64/lib/node_modules/npm/node_modules/pacote/lib/fetchers/registry/fetch.js:42:19)
20 verbose stack     at tryCatcher (/home/release/nodejs/node-v8.11.1-linux-x64/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23)
20 verbose stack     at Promise._settlePromiseFromHandler (/home/release/nodejs/node-v8.11.1-linux-x64/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:512:31)
20 verbose stack     at Promise._settlePromise (/home/release/nodejs/node-v8.11.1-linux-x64/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:569:18)
20 verbose stack     at Promise._settlePromise0 (/home/release/nodejs/node-v8.11.1-linux-x64/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:614:10)
20 verbose stack     at Promise._settlePromises (/home/release/nodejs/node-v8.11.1-linux-x64/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:693:18)
20 verbose stack     at Async._drainQueue (/home/release/nodejs/node-v8.11.1-linux-x64/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:133:16)
20 verbose stack     at Async._drainQueues (/home/release/nodejs/node-v8.11.1-linux-x64/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:143:10)
20 verbose stack     at Immediate.Async.drainQueues (/home/release/nodejs/node-v8.11.1-linux-x64/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:17:14)
20 verbose stack     at runCallback (timers.js:794:20)
20 verbose stack     at tryOnImmediate (timers.js:752:5)
20 verbose stack     at processImmediate [as _immediateCallback] (timers.js:729:5)
21 verbose cwd /home/release/Desktop/artifactory/release
22 verbose Linux 4.15.0-65-generic
23 verbose argv "/home/release/nodejs/node-v8.11.1-linux-x64/bin/node" "/usr/local/bin/npm" "install"
24 verbose node v8.11.1
25 verbose npm  v5.6.0
26 error code E404
27 error 404 Not Found: @luciad/ria-core@^2019.0
28 verbose exit [ 1, true ]

Here’s the log when try this with NPM 6.9.0, on a Windows machine :

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'install' ]
2 info using npm@6.9.0
3 info using node@v10.16.3
4 verbose npm-session e99caa5e8a2881d2
5 silly install runPreinstallTopLevelLifecycles
6 silly preinstall release
7 info lifecycle @~preinstall: @
8 silly install loadCurrentTree
9 silly install readLocalPackageData
10 timing stage:loadCurrentTree Completed in 13ms
11 silly install loadIdealTree
12 silly install cloneCurrentTreeToIdealTree
13 timing stage:loadIdealTree:cloneCurrentTree Completed in 1ms
14 silly install loadShrinkwrap
15 timing stage:loadIdealTree:loadShrinkwrap Completed in 2ms
16 silly install loadAllDepsIntoIdealTree
17 http fetch GET 304 https://[DOMAIN]/artifactory/api/npm/product_release_npm/@luciad%2fria-core 143ms
18 http fetch GET 404 https://[DOMAIN]:443/artifactory/api/npm/product_release_npm/@luciad/ria-core/-/@luciad/ria-core-2019.0.1.tgz 12ms
19 silly fetchPackageMetaData error for @luciad/ria-core@^2019.0 404 Not Found - GET https://[DOMAIN]:443/artifactory/api/npm/product_release_npm/@luciad/ria-core/-/@luciad/ria-core-2019.0.1.tgz
20 http fetch GET 404 https://[DOMAIN]:443/artifactory/api/npm/product_release_npm/@luciad/ria-core/-/@luciad/ria-core-2019.0.1.tgz 10ms
21 silly fetchPackageMetaData error for @luciad/ria-core@^2019.0 404 Not Found - GET https://[DOMAIN]:443/artifactory/api/npm/product_release_npm/@luciad/ria-core/-/@luciad/ria-core-2019.0.1.tgz
22 timing stage:rollbackFailedOptional Completed in 0ms
23 timing stage:runTopLevelLifecycles Completed in 248ms
24 silly saveTree release
25 verbose stack Error: 404 Not Found - GET https://[DOMAIN]:443/artifactory/api/npm/product_release_npm/@luciad/ria-core/-/@luciad/ria-core-2019.0.1.tgz
25 verbose stack     at res.buffer.catch.then.body (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-registry-fetch\check-response.js:104:15)
25 verbose stack     at process._tickCallback (internal/process/next_tick.js:68:7)
26 verbose statusCode 404
27 verbose pkgid @luciad/ria-core@^2019.0
28 verbose cwd D:\Desktop\EXPERIMENT\artifactory\release
29 verbose Windows_NT 10.0.16299
30 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
31 verbose node v10.16.3
32 verbose npm  v6.9.0
33 error code E404
34 error 404 Not Found - GET https://[DOMAIN]:443/artifactory/api/npm/product_release_npm/@luciad/ria-core/-/@luciad/ria-core-2019.0.1.tgz
35 error 404
36 error 404 '@luciad/ria-core@^2019.0' is not in the npm registry.
37 error 404 You should bug the author to publish it (or use the name yourself!)
38 error 404 Note that you can also install from a
39 error 404 tarball, folder, http url, or git url.
40 verbose exit [ 1, true ]

Reproduction Steps

I have an Artifactory NPM repo named product_release_npm, with anonymous access disabled.

At the project level, I have an .npmrc file with the following content :

@luciad:registry=https://[DOMAIN]/artifactory/api/npm/product_release_npm/

At the user level, I have an .npmrc file with the following content :

//[DOMAIN]/artifactory/api/npm/product_thirdparty_npm/:_authToken=[AUTH_TOKEN]
//[DOMAIN]/artifactory/api/npm/product_release_npm/:_authToken=[AUTH_TOKEN]

My project’s package.json file looks like this :

{
  "dependencies": {
    "@luciad/ria-core": "^2019.0"
  }
}

Platform Info

I was able to reproduce this issue on several versions of NPM from NPM 5.0.0 upwards.

I was not able to reproduce this issue on NPM 4.2.0 or lower.

I was able to reproduce this in both Linux & Windows.

Worth asking from the Artifactory end too, which I see you have done: