Command vue init requires a global addon

醉酒当歌 提交于 2019-12-21 03:33:35

问题


When I tried to vue init webpack test-app, I got the following error:

Command vue init requires a global addon to be installed.
Please run npm install -g @vue/cli-init and try again.

This is what I did to install vue cli v3 beta6
npm install -g @vue/cli

This is the tutorial I followed
https://itnext.io/getting-started-vue-js-and-visual-studio-code-6990f92e918a

Apparently, the tutorial does not need to install @vue/cli-init. I am wondering why and how to solve this issue.

Side Notes: When I install like this npm install -g vue-cli it works as expected. I have found that vue-cli is a stable 2.9.x version.

Thanks a ton!


回答1:


Looking at vue-cli repository I see two different ways of scaffolding vue projects.

The v3 (beta) version, installed as npm install -g @vue/cli, creates projects using the following command:

vue create my-project

While the version 2.9.x, available at master branch, is installed as npm install -g vue-cli and it allows projects scaffolding with the following:

vue init <template-name> <project-name>

for example:

vue init webpack my-project

So, in your scenario, for v3 version you should use: vue create test-app.

Here you can find further information.




回答2:


From the vue-cli website, Vue CLI 3 uses the same vue binary , so it overwrites Vue CLI 2 (vue-cli). So if you need the legacy vue inityou should install the global bridge

npm install -g @vue/cli-init
# vue init now works exactly the same as vue-cli@2.x


来源:https://stackoverflow.com/questions/49768034/command-vue-init-requires-a-global-addon

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!