Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Command vue init requires a global addon

Tags:

vue.js

vue-cli

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!

like image 623
Minjun Yu Avatar asked Apr 11 '18 06:04

Minjun Yu


People also ask

Should Vue CLI be installed globally?

In my personal opinion, you should just install @vue/cli in your home or $HOME , and export the binaries from node modules bin folder to access it globally without providing a sudo password. Avoid the -g flag while installing.

What is VUE CLI service global?

@vue/cli-service-global is a package that allows you to run vue serve and vue build without any local dependencies. @vue/cli-service is a package that actually doing those vue serve and vue build , both @vue/cli-service-global and @vue/cli depend on it.

How do I know if VUE CLI is installed or not?

You can verify that it is properly installed by simply running vue , which should present you with a help message listing all available commands.

How do you fix Vue is not recognized as an internal or external command operable program or batch file?

To solve the error "'vue' is not recognized as an internal or external command, operable program or batch file", install the @vue/cli package globally by running npm install -g @vue/cli , restart your terminal and make sure your PATH environment variable is set up correctly.


3 Answers

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.

like image 94
P3trur0 Avatar answered Oct 30 '22 04:10

P3trur0


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 [email protected]
like image 41
Anoop D Avatar answered Oct 30 '22 03:10

Anoop D


Please install npm install -g @vue/cli-init. Hope this will solve your problem.

like image 25
Muflah Nasir Avatar answered Oct 30 '22 04:10

Muflah Nasir