且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2023-09-18 16:11:04

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

OK, so within minutes after posting the question, I found the answer myself here: https://github.com/npm/npm/issues/2119#issuecomment-5321857

问题似乎是 npm 在代理上使用 HTTPS 并不是那么好.将注册表 URL 从 HTTPS 更改为 HTTP 为我修复了它:

The issue seems to be that npm is not that great with HTTPS over a proxy. Changing the registry URL from HTTPS to HTTP fixed it for me:

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

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

I still have to provide the proxy config (through Authoxy in my case), but everything works fine now.

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

Seems to be a common issue, but not well documented. I hope this answer here will make it easier for people to find if they run into this issue.