create-vue icon indicating copy to clipboard operation
create-vue copied to clipboard

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

Open segevfiner opened this issue 3 years ago • 2 comments

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: https://github.com/vuejs/create-vue/commit/f4ac339764ebd06bd23705bbaabb14fa229c31a6#commitcomment-83124443

segevfiner avatar Sep 05 '22 20:09 segevfiner

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.

segevfiner avatar Sep 06 '22 23:09 segevfiner

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?

BabyLy233 avatar Sep 14 '22 12:09 BabyLy233

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)

mathmul avatar Apr 05 '23 08:04 mathmul

They are different templates with different features.

segevfiner avatar Apr 05 '23 08:04 segevfiner

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

mathmul avatar Apr 05 '23 08:04 mathmul

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.

segevfiner avatar Apr 05 '23 08:04 segevfiner

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

mathmul avatar Apr 05 '23 08:04 mathmul

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.

antoniogiroz avatar May 13 '23 16:05 antoniogiroz

npx clear-npx-cache

haoqunjiang avatar May 15 '23 04:05 haoqunjiang

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 https://github.com/npm/cli/pull/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.

haoqunjiang avatar Jul 28 '23 16:07 haoqunjiang