vue.js 三种方式安装(vue-cli)参考:https://blog.csdn.net/muzidigbig/article/details/80490884
nodejs下载:https://nodejs.org/zh-cn/download/
1.先安装vscode和node.js,node.js检查配置环境变量,在path中新增:C:\Program Files\nodejs
2.全局安装vue-cli,打开命令行执行命令 npm install -g vue-cli,卸载用uninstall
2.1安装cnpm npm的淘宝镜像:
永久替换淘宝镜像:npm config set registry http://registry.npmmirror.com
vscode中执行,对当前项目使用淘宝镜像:npm install -g cnpm --registry=http://registry.npmmirror.com
npm 淘宝镜像的安装,参考地址:https://zhuanlan.zhihu.com/p/166175735
3.安装webpack打包工具:npm install -g webpack,卸载用uninstall
4.创建vue项目,先建一个项目文件夹vuetest,然后在vscode进入到目录:cd E:\projects\vuetest,然后执行命令:vue init webpack vuetest,
创建vue项目,官网执行命令:npm init vue@latest
创建vue项目,官网参考:https://cn.vuejs.org/guide/quick-start.html#creating-a-vue-application
可能报错1,系统环境变量的原因,执行命令:npm config get prefix 获取相关目录,把这个目录加入到环境变量的path中去,然后再创建项目。
可能报错2:vue : 无法加载文件 C:\Users\XXX\AppData\Roaming\npm\vue.ps1,因为在此系统上禁止运行脚本。
解决办法:以管理员身份运行 Windows PowerShell,执行命令 set-ExecutionPolicy RemoteSigned 参考:https://blog.csdn.net/qq_40431271/article/details/106618785
5.执行命令:npm run dev,项目就跑起来了。
执行命令:npm run build,打包发布项目,在项目里会出现dist,就是打包好的文件。
今天安装vue-cli发现命令过时了,需要用:npm install --location=global vue-cli
创建vue3项目:https://www.cnblogs.com/fifteen-home/p/15015828.html
安装cli3.0: npm install @vue/cli -g
创建项目:vue create project_name 项目名需要全小写,不支持大写
https://vuejs.org/guide/quick-start.html#with-build-tools
格式化代码:插件搜索vetur,安装。然后打开file文件----->preferences首选项------>settings设置,搜索vetur.format.defaultFormatter.html,把选项置为js-beautify-html,然后用alt+shift+f即可。
淘宝镜像地址的域名变了:https://registry.npmmirror.com
https://registry.npmmirror.com/binary.html?path=node/
https://registry.npmmirror.com/binary.html?path=npm/
浙公网安备 33010602011771号