npm / npm/cli

npm-update does NOT follow SemVer

Open
#3,579 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Priority 2 Release 7.x
Dominant language
JavaScript
Stars
10.1k
Forks
4.7k
Avg merge
2d 2h
Merged PRs (30d)
19

Description

Is there an existing issue for this?
  • I have searched the existing issues
Current Behavior

The documentation states:

If the dependence were on ^0.4.0... Then npm update will install dep1@0.4.1, because that is the highest-sorting version that satisfies ^0.4.0 (>= 0.4.0 <0.5.0)

which is exactly how it behaves.

Also, the documentation states:

This command will update all the packages listed to the latest version (specified by the tag config), respecting the semver constraints of both your package and its dependencies (if they also require the same package).

Expected Behavior

These two above statements in documentation are logically incompatible. SemVer does NOT consider 0.4.1 as an upgrade from 0.4.0.

SemVer is defined at: https://semver.org. And it states specifically:

Major version zero (0.y.z) is for initial development. Anything MAY change at any time. The public API SHOULD NOT be considered stable.

https://semver.org/#spec-item-4

Steps To Reproduce

Recommendation:

Update the program behavior to actually support SemVer for the carat (^) operator.

-or-

Update documentation to clarify that this is NOT SemVer. And then actually implement a SemVer with some other operator.

Environment
  • OS: macOS 11.4
  • Node: 14
  • npm: 7

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the npm-update documentation and reproduce the caret behavior using the Node 14/npm 7 environment described. Resolve whether the command or the documentation should change, then verify that the selected behavior and SemVer explanation are consistent.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
cli, tooling
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.