设置国内源,这样你的下载速度会非常快:
npm set registry https://registry.npm.taobao.org
查看源:
npm config list
卸载原有的vue版本:
npm uninstall vue-cli -g
安装vue:
npm install @vue/cli -g
安装node-gyp
npm install -g node-gyp
创建项目前要先执行命令:
npm install -g @vue/cli-init
执行完后再执行命令:(文件名自己取)
vue init webpack 文件名
安装过程中一次提示如下:
project name(项目名称) # 按回车
project description(项目描述) # 按回车
author(作者) # 按回车
vue build(解释器) # 按回车
Install vue-router(路由) # 按y按回车
use aslantto lint your code(代码检查) # 按n按回车
set up unit tests(测试模块) # 按n按回车
setup e2e tests with night watch(是否安装e2e) # 按n按回车
should we run ’npm install’(是否选择npm方式) # 选第一个,按回车
运行完之后cd 到项目中,可以安装一些常用的包
npm install axios --save
npm install style-loader —-save
npm install heyui --save
npm install js-md5 --save
安装完之后可以直接启动
npm run dev
退出服务
ctrl + c
如果出现任何关于node依赖的问题导致服务无法启动,执行npm install无法解决的,则安装rimraf,然后进入项目目录下,执行rimraf node_modules 删除后,重新执行 npm install 安装依赖
安装rimraf
npm install rimraf -g
删除node_modules
rimraf node_modules
重新安装node_modules
npm install