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

npm create vue@3 doesn't seem to always grab the latest version #157

Closed
segevfiner opened this issue Sep 5, 2022 · 10 comments
Closed

npm create vue@3 doesn't seem to always grab the latest version #157

segevfiner opened this issue Sep 5, 2022 · 10 comments
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@segevfiner
Copy link

segevfiner commented Sep 5, 2022

Even using npm create vue@3 doesn't seem to always use the latest version, perhaps it needs to point to some dist-tag instead? Oh man, the behavior of npm/npx here is so confusing... and seems practically undocumented.

See: f4ac339#commitcomment-83124443

@segevfiner segevfiner changed the title npm create vue@3 doesn't seem to always grab the latest version npm create vue@3 doesn't seem to always grab the latest version Sep 5, 2022
@segevfiner
Copy link
Author

This is essentially crappy behavior of npm. I wonder how do yarn 1/2+ & pnpm fare in this regard. But this is something we might want to extend the warning in the README.md and docs for as it really caught me off guard.

@BabyLy233
Copy link

BabyLy233 commented Sep 14, 2022

Maybe I have the same problem. When I use npm init vue@3 , the project's dependency vite is old version 2.9
But the template project's dependency vite is 3.0. How to get the latest version of template when use npm init vue@3 ? By clean the npm cache?

@mathmul
Copy link

mathmul commented Apr 5, 2023

Isn't the vite way to do npm create vite@latest?
Source: vitejs.dev/guide

Why is npm create vue@3 considered the recommended way here? Recommended by whom? (Sincerely asking)

@segevfiner
Copy link
Author

They are different templates with different features.

@mathmul
Copy link

mathmul commented Apr 5, 2023

@segevfiner So this would be the same npm create vite@latest my-vue-app -- --template vue?

@segevfiner
Copy link
Author

npm create vite is create-vite which has a vue and vue-ts templates inside it. npm create vue is create-vue, a different template, also based on Vite and it has different features, it is not based or related to create-vite AFAIK.

@mathmul
Copy link

mathmul commented Apr 5, 2023

Thanks. And sorry. I shouldn't abduct the issue for a StackOverflow question.

@antoniogiroz
Copy link

I am experiencing a similar issue. Whenever I use the command npm create vue@3, I consistently receive an outdated version. However, the problem seems resolved when I utilize pnpm.

Is there a way to clear the npm cache? npm cache clean --force does not work.

@sodatea
Copy link
Member

sodatea commented May 15, 2023

npx clear-npx-cache

@sodatea sodatea added bug Something isn't working documentation Improvements or additions to documentation labels Jul 28, 2023
@sodatea
Copy link
Member

sodatea commented Jul 28, 2023

I dug a bit more in the npm source code, and now I realize it's never safe to rely on @3 to get the latest version.

Before npm/cli#5244 (npm v8.16.0), there were several bugs in the npx command (which npm create calls underlyingly) about caches, so npm create vue@3 might have worked coincidentally.
After that PR, it's clear that when requesting a version range, npx would do a local-first search in the cache:
https://github.com/npm/cli/blob/c1e01d97da3b775edf104de158ee5db5cf027d0d/workspaces/libnpmexec/lib/index.js#L54-L57

I think I need to update the documentations to use npm create vue@latest everywhere.

jasonreyes9 added a commit to jasonreyes9/create-vue-script that referenced this issue Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

5 participants