If you believe this might be a permissions issue, please double-check the permissions as root/Admini

在Windows和Linux上安装Vue时遇到npm错误代码EPERM,通常是由于文件权限问题。解决方案包括以管理员身份运行CMD,删除.npmrc文件,清除npm缓存以及修改文件夹权限。在Linux中,可以使用sudo命令提高权限。
摘要由CSDN通过智能技术生成

VUE安装出现的系统权限问题

PS D:\***> npm install -g create-vue     
npm ERR! code EPERM
npm ERR! syscall open
npm ERR! path D:\***\node_cache\_cacache\tmp\3acf1f0a
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, open 'D:\***\node_cache\_cacache\tmp\3acf1f0a'
npm ERR!  [Error: EPERM: operation not permitted, open 'D:\***\node_cache\_cacache\tmp\3acf1f0a'] {
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'open',
npm ERR!   path: 'D:\\***\\node_cache\\_cacache\\tmp\\3acf1f0a'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
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! Log files were not written due to an error writing to the directory: D:\***\node_cache\_logs
npm ERR! You can rerun the command with `--loglevel=verbose` to see the logs in your terminal

处理办法

win

1、使用管理员身份运行cmd(不推荐)
每次安装包,都要以管理员身份运行cmd,有点麻烦

2、删除npmrc文件(不推荐)
如果自己本身就是管理员权限,因而无用

3、需要删除npmrc文件。
强调:不是nodejs安装目录npm模块下的那个npmrc文件
而是在C:\Users\用户名下的.npmrc文件

4、清除缓存(没成功)
用命令清除缓存的,我自己试了下没成功,放弃(都没成功,说什么放弃),上面删除文件起码成功了。
cmd中运行npm cache clean --force

5、更改文件夹权限(推荐)
每次安装都要用管理员身份运行,主要因为安装nodejs时没有授予写的权限,找到nodejs安装文件夹更改权限即可。
右键nodejs安装文件夹>>>属性>>>安全>>>编辑>>>选择用户>>>勾选写入权限>>>应用

Linux

1、直接在前面加sudo
sudo npm install <包>

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

samRsa

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值