1. 在创建cli项目时,执行npm create 项目名; 注意名最好是英文 开头最好是小写;
2. npm create 命令是基于 vue.3.0 版本以上使用的,检查cli版本号 vue -V ;
3. 先卸载原有的cli
1 2 | npm uninstall vue-cli -g // 卸载原有cli npm install -g @vue/cli // 安装新版本cli |
4. 以上是没有出现问题,当有问题时,当你卸载vue.cli时会出现 up to time in 0.14s,等状况;mac版本;
5. 这里由于是mac版本改环境变量就不再赘述了,主要是刚入手mac不太了解
6。 我是把node和npm完全卸载处理代码如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | # 这里是卸载npm的 sudo npm uninstall npm -g # 这里是用来删除node创建的各种文件夹 sudo rm -rf /usr/local/lib/node sudo rm -rf /usr/local/lib/node_modules sudo rm -rf /var/db/receipts/org.nodejs.* sudo rm -rf /usr/local/include/node /Users/$USER/.npm* # 删除node命令 sudo rm /usr/local/bin/node # 删除node的所有man手册 sudo rm /usr/local/share/man/man1/node.1 sudo rm /usr/local/share/man/man1/npm-* sudo rm /usr/local/share/man/man1/npm.1 sudo rm /usr/local/share/man/man1/npx.1 sudo rm /usr/local/share/man/man5/npm* sudo rm /usr/local/share/man/man5/package.json.5 sudo rm /usr/local/share/man/man7/npm* # 这个命令也是删除一个node文件,但不知道这文件有什么用 sudo rm /usr/local/lib/dtrace/node.d // 然后执行命令会出现这样的结果 npm -v // 结果应该是 -bash: npm: command not found node -v // 结果应该是 -bash: node: command not found // 此处证明你已经删除了 npm 和 node |
7. 重新安装node 和 npm 官网上下载的直接Enter到底就ok了 , mac上可以通过brew安装node和npm 直接命令 brew install node
检测npm 和 node 安装 npm -v node -v
8. 在node和npm安装完成之后, 我的mac会出现 以下一些问题 报错
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | npm WARN deprecated [email protected]: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies. npm WARN [email protected] requires a peer of @babel/preset-env@^7.1.6 but none is installed. You must install peer dependencies yourself. npm ERR! code EEXIST npm ERR! syscall symlink npm ERR! path ../lib/node_modules/@vue/cli/bin/vue.js npm ERR! dest /usr/local/bin/vue npm ERR! errno -17 npm ERR! EEXIST: file already exists, symlink '../lib/node_modules/@vue/cli/bin/vue.js' -> '/usr/local/bin/vue' npm ERR! File exists: /usr/local/bin/vue npm ERR! Remove the existing file and try again, or run npm npm ERR! with --force to overwrite files recklessly. npm ERR! A complete log of this run can be found in: npm ERR! /Users/521azheng/.npm/_logs/2020-06-21T09_47_02_656Z-debug.log 521azhengdeMacBook-Pro:vue-hm-pc 521azheng$ sudo npm install -g @vue/cli |
在看过很很多教程之后 发现是权限不够 要按照管理身份印证 所以这里用 sudo 执行命令, 这里注意有可能一次执行还会报错失败,回报 errno -13 ,这时需要重复执行下面的命令就可以得到最新的 cli了
1 | sudo npm install -g @vue/cli |