【问题标题】:npm install now always throws errno EACCES errornpm install 现在总是抛出 errno EACCES 错误
【发布时间】:2020-08-18 17:57:49
【问题描述】:

当我使用 npm 安装任何东西时(例如npm i json-stream

我收到以下错误:

npm ERR! code EACCES
npm ERR! errno EACCES
npm ERR! FetchError: request to https://registry.npmjs.org/json-stream failed, reason: connect EACCES 104.16.25.35:443 - Local (0.0.0.0:0)
npm ERR!     at ClientRequest.<anonymous> (/Users/maxfowler/.nvm/versions/node/v12.16.3/lib/node_modules/npm/node_modules/node-fetch-npm/src/index.js:68:14)
npm ERR!     at ClientRequest.emit (events.js:310:20)
npm ERR!     at TLSSocket.socketErrorListener (_http_client.js:426:9)
npm ERR!     at TLSSocket.emit (events.js:310:20)
npm ERR!     at emitErrorNT (internal/streams/destroy.js:92:8)
npm ERR!     at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
npm ERR!     at processTicksAndRejections (internal/process/task_queues.js:84:21)
npm ERR!  FetchError: request to https://registry.npmjs.org/json-stream failed, reason: connect EACCES 104.16.25.35:443 - Local (0.0.0.0:0)
npm ERR!     at ClientRequest.<anonymous> (/Users/maxfowler/.nvm/versions/node/v12.16.3/lib/node_modules/npm/node_modules/node-fetch-npm/src/index.js:68:14)
npm ERR!     at ClientRequest.emit (events.js:310:20)
npm ERR!     at TLSSocket.socketErrorListener (_http_client.js:426:9)
npm ERR!     at TLSSocket.emit (events.js:310:20)
npm ERR!     at emitErrorNT (internal/streams/destroy.js:92:8)
npm ERR!     at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
npm ERR!     at processTicksAndRejections (internal/process/task_queues.js:84:21) {
npm ERR!   type: 'system',
npm ERR!   errno: 'EACCES',
npm ERR!   code: 'EACCES'
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:
npm ERR!     /Users/maxfowler/.npm/_logs/2020-05-04T10_18_22_396Z-debug.log

我在 mac OS 10.14 上使用 nvm。我试过以 sudo 和不同的工作目录运行命令。有什么想法吗?

我也尝试过ping 104.16.25.35(有效)和ping 104.16.25.35:443,它返回ping: cannot resolve 104.16.25.35:443: Unknown host

【问题讨论】:

  • 即使在完全卸载 node 和 nvm 然后为我的用户重新安装 nvm 之后,我仍然遇到同样的错误,但是,在同一台计算机上的不同 mac 用户上,我安装了 nvm,它正在工作.. . 所以我仍然不知道我的用户帐户有什么问题
  • 嗯,现在又不能在我的其他 mac 用户上工作了,同样的错误。

标签: node.js npm nvm


【解决方案1】:

尝试以超级用户模式安装它,在命令中添加 sudo,如 sudo npm i json-stream

【讨论】:

    【解决方案2】:

    当您使用 sudo 安装 node 或 npm 时会发生这种情况。我认为您正在将 nvm 与 sudo 一起使用? IMO 是个坏主意。一个解决方案可以是重新chown你的nvm和子文件夹给你的用户,或者在没有sudo的情况下重新安装/Users/maxfowler/.nvm/文件夹。我假设这个属于root用户。

    另一方面,如果您需要一次性执行json-stream,我建议使用npx 调用作为npx json-stream。这样您就不会在您的计算机上安装任何东西。

    【讨论】:

      【解决方案3】:

      我发现我的 ~/.npmrc 文件的权限为 600。我删除了这个文件,然后似乎一切都恢复了。

      我不是 100% 确定这是修复它的原因,但似乎是这样。我的 .nvm 和 .npm 目录否则具有正确的权限,这不是问题。

      【讨论】:

      • 可以确认不修复错误。
      猜你喜欢
      • 2021-12-18
      • 1970-01-01
      • 1970-01-01
      • 2017-06-21
      • 2021-09-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多