简体   繁体   中英

Vue create project

Can anyone explain to me why I need to run npm install -g @vue/cli every time before creating new VUE project? and also after installing vue/cli I am unable to create project with running vue create project-name . It is throwing this error > Error: spawn yarn ENOENT and the project is created only by this command > vue create -m npm project-name

Well since you have multiple question in your post I will attempt to separate it.

1. Why I need to run npm i -g @vue/cli every time

No you don't need to. With -g flag it means global installation. Without -g , it means that the dependency only exist in the project. But global flag basically allows the dependency to be access through your entire system.

2. Unable to create project

With a simple google search , users report that the issue is likely that you don't have yarn in your system, or some broken files, as your question lack of specification of details, please refer to the link and find a fix within the post that is most suitable for your system / case.

Side Note:

Based on the github repo of Vue Cli,

Vue CLI is now in maintenance mode. For new projects, please use create-vue to scaffold Vite-based projects. create-vue supports both Vue 2 and Vue 3.

you probably want to stick with Vite instead of Vue CLI unless you are maintaining legacy projects.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM