【问题标题】:npm ERR! Error: EACCES: permission denied, opennpm 错误!错误:EACCES:权限被拒绝,打开
【发布时间】:2019-06-13 11:33:32
【问题描述】:

我正在尝试使用 npm install 从已经存在的 react 项目安装我的依赖项,但是,现在每次尝试运行 npm install 时都会给我这个错误。

有谁知道为什么现在会发生这种情况?我有几个项目在安装和卸载之前一直在做,完全没有问题。

npm WARN deprecated fsevents@2.0.6: Please update: there are crash fixes
npm WARN deprecated left-pad@1.3.0: use String.prototype.padStart()
npm ERR! path /Users/gabrielnessi/.npm/_cacache/index-v5/35/e4/300bcd6d6b07328b3cffb3509f86bc1ac535a870f8fe27c074a299d8c732
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall open
npm ERR! Error: EACCES: permission denied, open '/Users/gabrielnessi/.npm/_cacache/index-v5/35/e4/300bcd6d6b07328b3cffb3509f86bc1ac535a870f8fe27c074a299d8c732'
npm ERR!  [OperationalError: EACCES: permission denied, open '/Users/gabrielnessi/.npm/_cacache/index-v5/35/e4/300bcd6d6b07328b3cffb3509f86bc1ac535a870f8fe27c074a299d8c732'] {
npm ERR!   cause: [Error: EACCES: permission denied, open '/Users/gabrielnessi/.npm/_cacache/index-v5/35/e4/300bcd6d6b07328b3cffb3509f86bc1ac535a870f8fe27c074a299d8c732'] {
npm ERR!     errno: -13,
npm ERR!     code: 'EACCES',
npm ERR!     syscall: 'open',
npm ERR!     path: '/Users/gabrielnessi/.npm/_cacache/index-v5/35/e4/300bcd6d6b07328b3cffb3509f86bc1ac535a870f8fe27c074a299d8c732'
npm ERR!   },
npm ERR!   isOperational: true,
npm ERR!   stack: 'Error: EACCES: permission denied, open ' +
npm ERR!     "'/Users/gabrielnessi/.npm/_cacache/index-v5/35/e4/300bcd6d6b07328b3cffb3509f86bc1ac535a870f8fe27c074a299d8c732'",
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'open',
npm ERR!   path: '/Users/gabrielnessi/.npm/_cacache/index-v5/35/e4/300bcd6d6b07328b3cffb3509f86bc1ac535a870f8fe27c074a299d8c732',
npm ERR!   parent: 'eslint-plugin-jsx-a11y'
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 (though this is not recommended).

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/gabrielnessi/.npm/_logs/2019-06-13T11_28_05_702Z-debug.log```

【问题讨论】:

  • 某些依赖项需要您拥有超级用户访问权限。试试 sudo npm install
  • @MehulMittal 这是第二次发生,也是我第一次用 sudo 解决,是的,但我不想每次必须安装软件包时都使用 sudo,有没有办法获得我的权限吗?谢谢
  • 你的项目的路径是什么
  • @MehulMittal Documents/react_course/react-complete-guide(在 macbook 上)
  • 执行npm cache cleannpm cache clean --force 如果它不起作用,请尝试使用sudo。因为很可能您的缓存已损坏。然后安装软件包。

标签: node.js


【解决方案1】:

您可能以 root 身份创建项目,现在您尝试将模块安装在与简单用户相同的文件夹中。您需要以 root 身份登录以授予用户权限,或更改文件夹所有者或删除并重新创建您的项目文件夹

【讨论】:

  • 对。更多信息,只需将您的用户添加为 /Users/gabrielnessi/.npm/ 的所有者。试试sudo chown -R $USER /Users/gabrielnessi/.npm/。当然用正确的用户名或路径替换 gabrielnessi。
猜你喜欢
  • 2021-07-22
  • 2019-10-28
  • 2017-12-29
  • 1970-01-01
  • 2018-03-01
  • 2021-07-28
  • 2016-11-14
  • 2016-01-26
  • 1970-01-01
相关资源
最近更新 更多