npm i 报错 The operation was rejected by your operating system

昨天晚上我把C:\Program Files里的node_cache、node_global文件夹移动到d盘,今早装依赖的时候,就报错没有权限或者文件正在被某个应用运行的错误,类似于下面这种:

npm ERR! path /Users/Kyle/.npm/_cacache/index-v5/d8/1f/98ab242d0cbad080828ef3e3f4b864c25e506a719121c293fec810b14b3c
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall open
npm ERR! Error: EACCES: permission denied, open '/Users/Kyle/.npm/_cacache/index-v5/d8/1f/98ab242d0cbad080828ef3e3f4b864c25e506a719121c293fec810b14b3c'
npm ERR!  { [Error: EACCES: permission denied, open '/Users/Kyle/.npm/_cacache/index-v5/d8/1f/98ab242d0cbad080828ef3e3f4b864c25e506a719121c293fec810b14b3c']
npm ERR!   cause:
npm ERR!    { Error: EACCES: permission denied, open '/Users/Kyle/.npm/_cacache/index-v5/d8/1f/98ab242d0cbad080828ef3e3f4b864c25e506a719121c293fec810b14b3c'
npm ERR!      errno: -13,
npm ERR!      code: 'EACCES',
npm ERR!      syscall: 'open',
npm ERR!      path:
npm ERR!       '/Users/Kyle/.npm/_cacache/index-v5/d8/1f/98ab242d0cbad080828ef3e3f4b864c25e506a719121c293fec810b14b3c' },
npm ERR!   isOperational: true,
npm ERR!   stack:
npm ERR!    'Error: EACCES: permission denied, open \'/Users/Kyle/.npm/_cacache/index-v5/d8/1f/98ab242d0cbad080828ef3e3f4b864c25e506a719121c293fec810b14b3c\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'open',
npm ERR!   path:
npm ERR!    '/Users/Kyle/.npm/_cacache/index-v5/d8/1f/98ab242d0cbad080828ef3e3f4b864c25e506a719121c293fec810b14b3c',
npm ERR!   parent: 'findup-sync' }
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 (though this is not recommended).

报错内容写的是The operation was rejected by your operating system.It is likely you do not have the permissions to access this file as the current user,

If you believe this might be a permissions issue, please double-check the permissions of the file and its containing directories

也就是node文件夹下某个文件没有权限运行;或者文件正在被某个应用运行。

对于我来说应该是移动了磁盘位置后,没有权限,谷歌了下,需要找到node安装目录,右键属性,点击安全,设置users用户完全控制权限。

结果操作的时候又提示

将安全信息应用到以下对象时发生错误无法枚举容器中的对象访问被拒绝node\install_tools.bat

又谷歌了下,找到答案:无法枚举容器内对象 访问被拒绝? - 知乎

第一步:文件夹右键——“安全”选项卡——“高级”选项卡——更改“所有者”——输入“Administrators”,再勾选上【替换子容器和对象的所有者】,点确定退出“高级”选项卡。然后再点确定退出“属性”选项卡。

[注意Administrators是复数形式!]

第二步:依照第一步再次打开“高级”选项卡。如果界面有“继续”就点“继续”。如果没有就点所有者右边的“更改”按钮,出现“选择用户或组”对话框之后点“取消”。(这步是作为管理员的你的正常提权操作,不理解也没关系,照做就是)

第三步:点下面“禁用继承”按钮,全部转为“显式权限”。然后把所有包含“拒绝”字眼的权限条目删除。再然后点“添加”,添加“Users”的“完全控制”权限(如果已经有了就不用添加了)。

第四步:勾选“使用可从此对象继承的权限替换所有子对象的权限”,确定。

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值