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 init <package> doesn't use newer version if existing version is semver-major incompatible #3444

Closed
1 task done
Tracked by #403
giltayar opened this issue Jun 20, 2021 · 3 comments
Closed
1 task done
Tracked by #403
Labels
Bug thing that needs fixing Priority 2 secondary priority issue Release 7.x work is associated with a specific npm 7 release

Comments

@giltayar
Copy link

giltayar commented Jun 20, 2021

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
@giltayar giltayar added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels Jun 20, 2021
@wraithgar wraithgar added Priority 2 secondary priority issue and removed Needs Triage needs review for next steps labels Jul 1, 2021
@wraithgar wraithgar assigned wraithgar and unassigned wraithgar Jul 1, 2021
@k8w
Copy link

k8w commented Oct 17, 2021

Still have this problem.

My package is create-tsrpc-app.

It seems npx create-tsrpc-app always get the latest version of ^0, but the actual latest major version is 1.x.

To test it:

npx create-tsrpc-app -v

Get 0.2.13

npx create-tsrpc-app@latest -v

Get 1.x

@ruyadorno
Copy link
Collaborator

#4929 is related to this, I would appreciate if anyone can confirm if the issue is still happening after updating to npm@8.12.0

@wraithgar
Copy link
Member

This does appear to be fixed now.

~/D/n/s/init $ npm init @gar/test@1
Need to install the following packages:
  @gar/create-test@1.0.20
Ok to proceed? (y) 
Gar's test create script version 1.0.20
~/D/n/s/init $ npm init @gar/test
Need to install the following packages:
  @gar/create-test@2.0.3
Ok to proceed? (y) 
Gar's test create script version 2.0.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Priority 2 secondary priority issue Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

No branches or pull requests

4 participants