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


//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

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

$ 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

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.