npm 使用 https 会报错

2023-05-14 21:21:58 +08:00
 monster1priest

clash 开的增强模式,终端已设置export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890

npm 的 registry 如下设置为 http 时:

registry = "http://registry.npmjs.org/"

可以成功安装,但是会显示warning

npm notice Beginning October 4, 2021, all connections to the npm registry - including for package installation - must use TLS 1.2 or higher. You are currently using plaintext http to connect. Please visit the GitHub blog for more information: https://github.blog/2021-08-23-npm-registry-deprecating-tls-1-0-tls-1-1/

npm notice Beginning October 4, 2021, all connections to the npm registry - including for package installation - must use TLS 1.2 or higher. You are currently using plaintext http to connect. Please visit the GitHub blog for more information: https://github.blog/2021-08-23-npm-registry-deprecating-tls-1-0-tls-1-1/

npm 的 registry 换成 https 时:

registry = "https://registry.npmjs.org/"

会报错:

npm ERR! code ECONNRESET
npm ERR! errno ECONNRESET
npm ERR! network Invalid response body while trying to fetch https://registry.npmjs.org/@types%2fnode: aborted
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'
1339 次点击
所在节点    程序员
9 条回复
november
2023-05-14 21:27:54 +08:00
同样,国内使用 https 安装 github 上的项目的时候,也是报错。不过多次安装总有一次成功的。

另外,我用的 yarn ,yarn 打印出 registry 的时候,是 yarn 的地址,但是实际安装却是走的腾讯的源,没找到什么说法。
2218675712
2023-05-14 21:35:06 +08:00
建议 npm 不设置代理,clash 开 tun 模式
ChrisFreeMan
2023-05-14 21:53:32 +08:00
老毛病了,一般都是加密 VPN 的性能问题(连接上限瓶颈?),我用一些非针对 GFW 加密的 VPN 是可以很流畅的使用 npm 的,但是很快会被识别然后 IP 被封掉,头疼。
lete
2023-05-14 21:59:03 +08:00
要不试试这个看行不行,https://github.com/CreateWheel/mini-nrm
ncepuzs
2023-05-14 22:01:20 +08:00
开了增强模式为什么还要设置 http_proxy 环境变量?虽然感觉应该不会冲突……
看报错信息似乎要通过 npm config 设置 proxy ,没用过
另外,可以先尝试换大陆镜像源
C47CH
2023-05-14 22:11:09 +08:00
用 https_proxy 环境变量和 xray 没出过问题。
Track13
2023-05-14 23:03:27 +08:00
clash 开 tun 吧
duzhuo
2023-05-15 08:15:21 +08:00
coyoteer
2023-05-15 14:55:53 +08:00
把你的 clash 关了,感觉设国内镜像源和 clash 之间有冲突,pip 有时也会这样

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/939948

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX