代理后面的 npm 失败,状态为 403

新手上路,请多包涵

我正在尝试在代理后面运行 npm 。我尝试过直接或通过 Authoxy 输入代理:

 npm config set proxy http://localhost:8999
npm config set https-proxy http://localhost:8999

无论我使用哪个代理,在运行 npm search 时总是会遇到相同的错误:

 npm info it worked if it ends with ok
npm verb cli [ 'node', '/usr/local/bin/npm', 'search' ]
npm info using npm@1.1.45
npm info using node@v0.8.4
npm verb config file /Users/xxx/.npmrc
npm verb config file /usr/local/etc/npmrc
npm verb config file /usr/local/lib/node_modules/npm/npmrc
npm WARN Building the local index for the first time, please be patient
npm verb url raw /-/all
npm verb url resolving [ 'https://registry.npmjs.org/', './-/all' ]
npm verb url resolved https://registry.npmjs.org/-/all
npm info retry registry request attempt 1 at 09:48:47
npm http GET https://registry.npmjs.org/-/all
npm info retry will retry, error on last attempt: Error: tunneling socket could not be established, sutatusCode=403
npm info retry registry request attempt 2 at 09:48:57
npm http GET https://registry.npmjs.org/-/all
npm info retry will retry, error on last attempt: Error: tunneling socket could not be established, sutatusCode=403
npm info retry registry request attempt 3 at 09:49:57
npm http GET https://registry.npmjs.org/-/all
npm ERR! Error: tunneling socket could not be established, sutatusCode=403
npm ERR!     at ClientRequest.onConnect (/usr/local/lib/node_modules/npm/node_modules/request/tunnel.js:148:19)
npm ERR!     at ClientRequest.g (events.js:185:14)
npm ERR!     at ClientRequest.EventEmitter.emit (events.js:115:20)
npm ERR!     at Socket.socketOnData (http.js:1383:11)
npm ERR!     at TCP.onread (net.js:410:27)

该命令总是以 sutatusCode [原文如此!] 403 失败 - 这意味着未经授权。我已将 Authoxy 设置为不需要用户名/密码。当我绕过 Authoxy 并以 http://user:pass@proxy:port 的形式为我们的 NTLM 代理提供真正的代理凭据时,也会发生同样的错误。

如何通过代理完成这项工作?

更新

我在 NPM 项目上创建了一个问题来报告此问题: https ://github.com/isaacs/npm/issues/2866

原文由 nwinkler 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 1.5k
2 个回答

好的,所以在发布问题后的几分钟内,我自己在这里找到了答案: https ://github.com/npm/npm/issues/2119#issuecomment-5321857

问题似乎是 npm 在代理上的 HTTPS 上并不是很好。将注册表 URL 从 HTTPS 更改为 HTTP 为我修复了它:

 npm config set registry http://registry.npmjs.org/

我仍然必须提供代理配置(在我的情况下通过 Authoxy),但现在一切正常。

似乎是一个常见问题,但没有很好的记录。我希望这里的答案能让人们更容易找到他们是否遇到这个问题。

原文由 nwinkler 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
logo
Stack Overflow 翻译
子站问答
访问
宣传栏