当我们执行npm install -g @vue-cli时候会报错:
npm ERR! Invalid tag name “@vue-cli” of package “@vue-cli”: Tags may not have any characters that encodeURIComponent encodes.
npm ERR! A complete log of this run can be found in: /Users/wuwenlu/.npm/_logs/2023-07-30T12_30_33_993Z-debug-0.log

仔细检查我们输入的命令,有误
应该是
npm install -g @vue/cli
再次报错:
npm install -g @vue/cli
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/@vue
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/@vue'
npm ERR! [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/@vue'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/@vue'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in: /Users/wuwenlu/.npm/_logs/2023-07-30T23_37_52_775Z-debug-0.log

再次用管理员输入该命令,发现成功了
sudo npm install -g @vue/cli
验证是否成功安装:
npm list -g

在尝试使用npm全局安装@vue/cli时遇到了两个错误:首先,由于特殊字符导致的无效标签名错误,正确命令应为`npminstall-g@vue/cli`。其次,由于权限问题无法在`/usr/local/lib/node_modules/`下创建目录。通过使用sudo权限运行命令,安装过程最终成功。验证命令`npmlist-g`显示@vue/cli已全局安装。



1万+

被折叠的 条评论
为什么被折叠?



