【安装vue脚手架报错:npm install -g @vue-cli pm ERR! code EINVALIDTAGNAME 】

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

当我们执行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

在这里插入图片描述

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值