Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] npm view package@latest exits with code 0 and no output if latest tag does not exist #6408

Closed
2 tasks done
mcous opened this issue Apr 29, 2023 · 2 comments
Closed
2 tasks done
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 9.x work is associated with a specific npm 9 release

Comments

@mcous
Copy link

mcous commented Apr 29, 2023

Is there an existing issue for this?

  • I have searched the existing issues

I found #4029, but the issue was closed with no resolution. I am requesting a different "expected behavior" than that ticket.

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

If the latest tag does not exist, npm view package and npm view package@latest will exit with code 0 and empty output.

This causes problems with tools / CI flows that use npm view to list existing versions of a package, especially with third-party registries.

Expected Behavior

I would expect an E404, like what happens with you reference a different tag that does not exist, like npm view example@foobar.

Steps To Reproduce

This is a bit difficult to reproduce, because the npm registry appears to automatically create the latest tag for a newly published package, even if you publish to a different tag.

The GitHub NPM Package Repository, however, does not do this, so it's possible to create a package that has no latest tag. I have created a public package that exhibits this behavior.

This reproduction requires a GitHub Personal Access token configured for the //npm.pkg.github.com/:_authToken config setting.

# exit code 0
❯ npm_config_registry=https://npm.pkg.github.com/ npm view "@tracespace/parser@next" versions dist-tags
versions = '5.0.0-alpha.0'
dist-tags = { next: '5.0.0-alpha.0' }

# exit code 1
❯ npm_config_registry=https://npm.pkg.github.com/ npm view "@tracespace/parser@not-a-tag" versions dist-tags
npm ERR! code E404
npm ERR! 404 No match found for version not-a-tag
npm ERR! 404
npm ERR! 404  '@not-a-tag' is not in this registry.
npm ERR! 404 This package name is not valid, because
npm ERR! 404  1. name can only contain URL-friendly characters
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in: /Users/mc/.npm/_logs/2023-04-29T17_08_32_549Z-debug-0.log

# exit code 0, no output on stdout nor stderr
❯ npm_config_registry=https://npm.pkg.github.com/ npm view "@tracespace/parser@latest" versions dist-tags

Environment

  • npm: 9.6.5
  • Node.js: 18.13.0
  • OS Name: macOS 13.3.1 (22E261)
  • System Model Name: iMac Pro
  • npm config:
; "user" config from /Users/mc/.npmrc

//npm.pkg.github.com/:_authToken = (protected)

; node bin location = /Users/mc/.nvs/node/18.13.0/x64/bin/node
; node version = v18.13.0
; npm local prefix = /Users/mc/projects/tracespace/packages/parser
; npm version = 9.6.5
; cwd = /Users/mc/projects/tracespace/packages/parser
; HOME = /Users/mc
; Run `npm config ls -l` to show all defaults.

; "publishConfig" from /Users/mc/projects/tracespace/packages/parser/package.json
; This set of config values will be used at publish-time.

access = "public"
registry = "https://npm.pkg.github.com/"
tag = "next"
@mcous mcous added Bug thing that needs fixing Needs Triage needs review for next steps Release 9.x work is associated with a specific npm 9 release labels Apr 29, 2023
@mcous mcous changed the title [BUG] <title> [BUG] npm view package@latest exits with code 0 and no output if latest tag does not exist Apr 29, 2023
@mcous
Copy link
Author

mcous commented Sep 13, 2023

Closing due to lack of interest / response

@mcous mcous closed this as not planned Won't fix, can't repro, duplicate, stale Sep 13, 2023
@PieterT2000
Copy link

Bumping this up, I just got the same error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 9.x work is associated with a specific npm 9 release
Projects
None yet
Development

No branches or pull requests

2 participants