cli icon indicating copy to clipboard operation
cli copied to clipboard

[BUG] Running `npm deprecate package@version "reason"` silently fails when no versions match

Open tlhunter opened this issue 1 year ago • 0 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

This issue exists in the latest npm version

  • [X] I am using the latest npm

Current Behavior

While executing the following command:

npm deprecate [email protected] "message"

The command exits with a status code of 0 and no output. This is because the dd-trace-js package doesn't have a version 4.21.0 associated with it. This was due to my error, I meant to use npm deprecate dd-trace but had made a typo.

Overall this caused some head scratching. Even the --verbose output didn't provide any hints, everything was happy 200 responses.

Expected Behavior

I would expect the command to display a warning message when the operation matches 0 package versions.

I suspect the command "succeeds" conceptually as the command really means "deprecate the given range of packages" and that range is 0 packages. But really I want a warning that no package versions matched the range to help me debug the situation.

Steps To Reproduce

  1. Using macOS
  2. Authenticate using auth flow with npm adduser and supplying OTP via website
  3. Run npm deprecate package-name@version "reason"
  4. See that nothing happens

Environment

  • npm: 10.4.0, 10.3.0
  • Node.js: 18.19.0, 20.11.0, 20.10.0
  • OS Name: macOS
  • System Model Name: Darwin Kernel Version 23.2.0 / Apple M1 Max
  • npm config:
; "user" config from /Users/thomas.hunter/.npmrc

//registry.npmjs.org/:_authToken = (protected)

; node bin location = /Users/thomas.hunter/.nvm/versions/node/v20.11.0/bin/node
; node version = v20.11.0
; npm local prefix = /Users/thomas.hunter/Projects/dd-trace-js
; npm version = 10.4.0
; cwd = /Users/thomas.hunter/Projects/dd-trace-js
; HOME = /Users/thomas.hunter
; Run `npm config ls -l` to show all defaults.

tlhunter avatar Jan 26 '24 18:01 tlhunter