Skip to content

[BUG] npm init <package> doesn't use newer version if existing version is semver-major incompatible #3444

@giltayar

Description

@giltayar

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

(the use of @roundforest is just an example.)

Using npm init @scope will use the latest version of the package, but only if the latest version is semver-minor/patch compatible with the version last used in nm init @scope. If it is semver-major changed, then it will continue to use the older version.

Expected Behavior

Always use the latest version of the init package, even if the semver-major version of the package is larger.

Steps To Reproduce

  1. Run npm init @roundforest to run the @roundforest/create, which is currently at version 1.0.0. Works!
  2. Publish a new version of @roundforest/create, version 1.1.0.
  3. Run npm init @roundforest to run the @roundforest/create. It will ask to use v1.1.0, and uses it. Yay!
  4. Now publish a new version of @roundforest/create, version 2.0.0 (semver incompatible with 1.1.0.
  5. Run npm init @roundforest to run the @roundforest/create. It will NOT use version 2.0.0, even though I expect it to.
  6. If I delete the npx cache of npm init, and try npm init @roundforest again, it will use version 2.0.0

Environment

  • OS: macOS Big Sur
  • Node: 16.3.0.
  • npm: 7.15.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingPriority 2secondary priority issueRelease 7.xwork is associated with a specific npm 7 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions