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

[DOCS] npm init doesn't use @latest package version if already installed globally #3821

Closed
1 task done
Tracked by #403
slorber opened this issue Oct 1, 2021 · 9 comments
Closed
1 task done
Tracked by #403
Assignees
Labels
Bug thing that needs fixing Priority 1 high priority issue Release 7.x work is associated with a specific npm 7 release

Comments

@slorber
Copy link

slorber commented Oct 1, 2021

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Run npm init docusaurus -- -V

image

publish 0.0.6

Run again:

image


I have no idea why it says:

Need to install the following packages:
  create-docusaurus
Ok to proceed? (y)

It even shows a download progress bar, and then the version stays at 0.0.5, despite 0.0.6 being published.

image

Expected Behavior

After 0.0.6 publish, it should use that newly published version instead of the already installed one.

This is also the behavior of yarn create docusaurus -V

Steps To Reproduce

See above

Environment

  • OS: MacOS
  • Node: 16.10
  • npm: 7.24.0

Could also reproduce on npm 6 / Node 12

@slorber slorber 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 Oct 1, 2021
@slorber
Copy link
Author

slorber commented Oct 1, 2021

This has already been discussed here: #2395

cc @wraithgar wondering if there's an RFC or if this change is planned?

This is quite annoying because it forces to add npm init docusaurus@latest everywhere in our docs, leading to a more cryptic init command, harder to remember for our userbase that is not necessarily node devs.

@wraithgar
Copy link
Member

This would be a great thing to bring up at the RFC meeting. I know it would likely also benefit for instance the create-react-app folks as they are currently also working on ways to dissuade people from installing it globally (which is what triggers this behavior). Feel free to open up an RRFC https://github.com/npm/rfcs.

@slorber
Copy link
Author

slorber commented Oct 7, 2021

Hey @wraithgar , I'm not very familiar with this process, what is a "RRFC" compared to a regular RFC md doc?

Are those more casual RFCs opened as issues?

@slorber
Copy link
Author

slorber commented Oct 7, 2021

Note: some projects handle this problem by not including init templates inside the create-x package, but rather download the unversioned project templates from a repo's main branch or HTTP URL.

One example is https://github.com/remotion-dev/remotion/blob/main/packages/create-video/src/init.ts

@wraithgar
Copy link
Member

Hey @wraithgar , I'm not very familiar with this process, what is a "RRFC" compared to a regular RFC md doc?

Are those more casual RFCs opened as issues?

Exactly, it's basically the opening of a discussion to see if we even want an rfc or if the general consensus is to fix it as a bug. It's one of those formalities we like to adhere to so that decisions like this aren't made without giving the community a chance to give input.

It also helps leave a record of the decision, which is very helpful.

@lukekarrys lukekarrys added Priority 1 high priority issue and removed Needs Triage needs review for next steps labels Oct 20, 2021
lrills added a commit to machinat/sociably that referenced this issue Dec 24, 2021
wraithgar added a commit that referenced this issue Feb 17, 2022
@wraithgar wraithgar self-assigned this Feb 17, 2022
@wraithgar wraithgar changed the title [BUG] npm init should use @latest package version by default [DOCS] npm init doesn't use @latest package version if already installed globally Feb 17, 2022
lukekarrys pushed a commit that referenced this issue Feb 22, 2022
@slorber
Copy link
Author

slorber commented Mar 24, 2022

Hey, wondering if something changed in recent versions of Node? (on 16.14.2)

It seems to ask me much more often to confirm when trying to execute the same package twice

image

It wasn't the case before, we run this command in postinstall for a while now

@lukekarrys
Copy link
Contributor

I'm not sure if anything has changed in node, but if you can open a new issue I can investigate.

@slorber
Copy link
Author

slorber commented Mar 25, 2022

reported here: #4619

@benmccann
Copy link

This is quite annoying because it forces to add npm init docusaurus@latest everywhere in our docs, leading to a more cryptic init command, harder to remember for our userbase that is not necessarily node devs.

This behavior is extremely frustrating as a package maintainer. We've had to do the same, which you can see on the homepage of https://svelte.dev/ and many other places in our docs.

I understand that this limitation has now been documented, but can we consider improving the behavior here?

I'm also not sure what it means for a create package to be installed globally. I can't imagine that I ever ran npm install -g create-svelte. I assume it just means that I ran npm create svelte and it installed it globally on my behalf

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 1 high 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