You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用MITMproxy 9.0.1执行npm install时出现ECONNRESET错误求助

代理环境下npm install遇ECONNRESET错误(MITMproxy 9.0.1)

执行步骤

使用构建机本地部署的MITMproxy 9.0.1执行npm install,命令如下:

# 清除缓存和产物
rm -rf package-lock.json ~/.npm node_modules
# 启动代理
mitmdump --set stream_large_bodies=1m --ssl-insecure --listen-port 8989 &> stdout.txt &
# 构建命令
npm install --registry=[registry] --force --legacy-peer-deps

错误信息

执行后抛出ECONNRESET错误:

npm ERR! code ECONNRESET
npm ERR! syscall read
npm ERR! errno ECONNRESET
npm ERR! network Invalid response body while trying to fetch [registry]/@angular-devkit%2fbuild-angular: read ECONNRESET
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'

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2023-03-16T16_07_07_514Z-debug-0.log

相关配置

.npmrc配置(Docker容器中以root用户测试)

cafile=/root/.mitmproxy/mitmproxy-ca-cert.pem
https-proxy=https://127.0.0.1:8989
proxy=http://127.0.0.1:8989

package.json配置

{
  "name": "mitmdump-test",
  "version": "0.0.0",
  "private": true,
  "dependencies": {
    "@angular-devkit/build-angular": "^15.1.1",
    "@angular/animations": "^15.1.0",
    "@angular/cli": "^15.1.1",
    "@angular/common": "^15.1.0",
    "@angular/compiler": "^15.1.0",
    "@angular/core": "^15.1.0",
    "@angular/forms": "^15.1.0",
    "@angular/platform-browser": "^15.1.0",
    "@angular/platform-browser-dynamic": "^15.1.0",
    "@angular/router": "^15.1.0"
  }
}

环境信息

操作系统

已在CentOS 8和Debian Bullseye测试,问题在容器与传统虚拟机环境中均复现。

配置调整

发现NPM+MITMproxy会因打开文件描述符过多触发异常,通过ulimit -n 4096调高上限后可暂时缓解,但未解决根本问题。

临时非最优方案

已找到三个可规避问题的操作,但均无法实际采用且未修复核心问题:

  • 降级MITMProxy:Mitmproxy 5.3.0+Python3.6.8组合可正常运行,而9.0.1+Python3.10.4+组合会出错
  • 使用sudo执行npm install:仅在非root用户环境下有效
  • 改用HTTP而非HTTPS访问registry:可正常执行,但不符合安全规范

注意:已确认并非SSL证书权限问题,CA文件权限配置正确。

内容的提问来源于stack exchange,提问作者emanmcdow1

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.27 15:02:10