npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

npm view package@version does not return 404 if that version does not exist (no result)

What I Wanted to Do

npm view package@version
where version does not exist

expected: 404 (this is what is returned if the package does not exist)

What Happened Instead

no result

Reproduction Steps

test package - kmm-test-version-404

npm view kmm-test-version-404 time

{ created: ‘2019-03-06T21:49:11.224Z’,
‘0.0.1’: ‘2019-03-06T21:49:11.331Z’,
modified: ‘2019-03-06T21:49:42.779Z’,
‘1.0.0’: ‘2019-03-06T21:49:24.762Z’,
‘2.0.0’: ‘2019-03-06T21:49:37.794Z’ }

//Test with version that is not present - no result returned
npm view kmm-test-version-404@3.0.0

//verify command works as expected if version is present
npm view kmm-test-version-404@1.0.0

kmm-test-version-404@1.0.0 | Proprietary | deps: none | versions: 3

security holding package
.
.
.
latest: 2.0.0

published 7 hours from now by kmm745

Details

Behaviour
//if package itself does not exist, 404 is returned, as expected
npm view kmm-test-version-404-2

npm ERR! code E404

npm ERR! 404 Not found : kmm-test-version-404-2

Platform Info

npm --versions 6.4.1 node -p process.platform
darwin


And another test. I would have as a minimum, a non zero exit code.

$ if npm view package@version;then echo "OK"; else echo "Not found"; fi
OK

$ if npm view npm@^6.9;then echo "OK"; else echo "Not found"; fi

npm@6.9.0 | Artistic-2.0 | deps: 122 | versions: 310
bla bla
OK