npm unistall vue-cli -g
或
yarn global remote vue-cli
npm config get prefix
缓存目录的安装位置:默认是和npm安装目录同级的 npm_cachel
清除文件夹中的全部文件
npm install @vue/cli -g
vue -V
npm install -g @vue/cli-init
vue init webpack 项目名称
vue create 项目名称
cd 项目名称
npm run serve ==> 默认是8080端口
如果提示serve不是一个内部或外部的命令则需要安装以下serve包:
npm i serve
虽然 3.x版本的脚手架中没有build文件夹,但依然可以通过
npm run build
打包生成dist文件夹
serve dist ==>默认是5000端口
npm run serve
或
yarn serve
package.json文件中 添加--open允许自动打开浏览器
"script":{"serve":"vue-cli-service serve --open"}