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

Node 6.10.1与npm 3.10.10执行npm install时遇socket hang up错误求助

Troubleshooting "Error: socket hang up" During npm install -d Behind Corporate cntlm Proxy

Hey there, let’s dig into this socket hang up issue you’re hitting with npm install -d behind your corporate cntlm proxy. I’ve dealt with plenty of proxy-related npm quirks, especially with older Node/npm versions like your 6.10.1/3.10.10 combo—these can have some tricky compatibility gaps with enterprise proxies. Here are targeted fixes tailored to your setup:

1. Adjust cntlm’s Connection & Timeout Settings

Older cntlm configs often struggle with npm’s parallel package pulls, which can overload the proxy and cause dropped connections. Edit your cntlm config file (usually /etc/cntlm.conf or ~/.cntlm.conf) and update these values:

  • Add Timeout 300 (extends the timeout to 5 minutes, enough for most package download sequences)
  • Set MaxConnections 10 (matches npm’s default parallel connection limit, prevents cntlm from rejecting excess requests)
  • Enable KeepAlive yes to maintain persistent connections with your upstream corporate proxy

After saving changes, restart cntlm to apply them:

sudo systemctl restart cntlm  # For systemd-based Ubuntu 16.04
# Or if using upstart: sudo service cntlm restart

2. Force npm to Use HTTP/1.1 (Disable HTTP/2)

Node 6.x’s HTTP module has known issues with HTTP/2 over proxies. Force npm to stick with HTTP/1.1 by setting these configs:

npm config set http-proxy http://localhost:3128  # Match your cntlm listening port
npm config set https-proxy http://localhost:3128
npm config set proxy http://localhost:3128
npm config set http2 false
# Only add this next line if your corporate proxy uses self-signed certs (common in enterprises):
npm config set strict-ssl false

3. Reduce npm’s Parallel Connection Limit

npm 3.x defaults to 50 parallel connections, which can overwhelm cntlm or your corporate proxy. Lower this to a more conservative number:

npm config set maxsockets 5

This cuts down on proxy load and reduces the chance of socket timeouts mid-install.

4. Clear npm Cache & Start Fresh

Corrupted cache entries can sometimes trigger unexpected connection hangs. Wipe the cache and reinstall:

npm cache clean --force
rm -rf node_modules package-lock.json
npm install -d

5. Validate cntlm’s Authentication

Double-check that cntlm is properly authenticated with your corporate proxy. Run a test curl to confirm traffic routes correctly:

curl -x http://localhost:3128 https://your-internal-registry-url  # Replace with your actual internal registry

If this fails, regenerate your cntlm authentication hashes with:

cntlm -M http://your-corporate-proxy:port

Update your cntlm config with the new hashes and restart the service before retrying npm.

6. Upgrade npm (Within Node 6.x Compatibility)

While you can’t upgrade Node, npm 3.10.10 is quite outdated. Node 6.10.1 supports up to npm 4.6.1, which includes better proxy handling fixes. Upgrade with:

npm install -g npm@4.6.1

I know you’ve already gone through a lot of solutions, but these are specific to your older Node/npm + cntlm setup. Hope one of these gets your installs running smoothly!

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 06:58:42