1. 创建脚手架
- 输入命令:npm install -g @vue/cli --force
- 出现以下报错:
npm WARN using --force Recommended protections disabled.
npm ERR! code EEXIST
npm ERR! syscall mkdir
npm ERR! path /Users/josie/.npm/_cacache/content-v2/sha512/58/8c
npm ERR! errno EEXIST
npm ERR! Invalid response body while trying to fetch https://registry.npmmirror.com/open: EACCES: permission denied, mkdir '/Users/josie/.npm/_cacache/content-v2/sha512/58/8c'
npm ERR! File exists: /Users/josie/.npm/_cacache/content-v2/sha512/58/8c
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: /Users/josie/.npm/_logs/2023-10-11T13_55_00_769Z-debug-0.log
- 检查vue版本:
josie@192 项目 % vue -V
zsh: command not found: vue
2. 重新安装脚手架
- 输入命令
sudo npm install -g vue-cli
Password:
npm WARN deprecated vue-cli@2.9.6: This package has been deprecated in favour of @vue/cli
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated consolidate@0.14.5: Please upgrade to consolidate v1.0.0+ as it has been modernized with several long-awaited fixes implemented. Maintenance is supported by Forward Email at https://forwardemail.net ; follow/watch https://github.com/ladjs/consolidate for updates and release changelog
npm WARN deprecated coffee-script@1.12.7: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
added 234 packages in 3s
3.查看帮助
josie@192 项目 % vue -help
Usage: vue <command> [options]
Options:
-V, --version output the version number
-h, --help output usage information
Commands:
init generate a new project from a template
list list available official templates
build prototype a new project
create (for v3 warning only)
help [cmd] display help for [cmd]
josie@192 项目 % vue -V
2.9.6
4.更新vue版本
-Vue-cli更新版本,需要先把旧的版本进行卸载,输入npm uninstall -g vue-cli
此时会出现卸载失败的情况,也就是查看版本的时候,版本还是原来的版本
-解决方法:找到原来安装vue的目录
which Vue
目录:
/usr/local/bin/Vue
打开命令终端,进入到这个目录中
cd /usr/local/bin
输入删除命令
sudo rm -rf vue vue-init
Password:
此时我们再查看的时候,命令终端会提示command not found : vue
josie@192 bin % vue -V
zsh: command not found: vue
此时将可以进行下载新的版本vue-cli
sudo npm install -g @vue/cli
下载成功后查看版本
josie@192 bin % vue -V
@vue/cli 5.0.8