Skip to content

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

@tlhunter

Description

@tlhunter

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions