在海外安装时 NPM 超时

lfe*_*445 4 node.js npm

我在美国以外的地方度假,那里的连接速度很慢,npm install给我带来了一些麻烦。

› npm config list
; cli configs
user-agent = "npm/3.7.3 node/v5.8.0 darwin x64"

; userconfig /Users/lfender/.npmrc
registry = "http://registry.npmjs.org/"
strict-ssl = false

; globalconfig /Users/lfender/.nvm/versions/node/v5.8.0/etc/npmrc
strict-ssl = false

; node bin location = /Users/lfender/.nvm/versions/node/v5.8.0/bin/node
; cwd = /Users/lfender/source/ag.js
; HOME = /Users/lfender
; "npm config ls -l" to show all defaults.

npm install --verbose
npm info retry will retry, error on last attempt: Error: connect ETIMEDOUT 151.101.56.162:443
Run Code Online (Sandbox Code Playgroud)

我已尝试将注册表设置为 ,http但看起来好像仍在尝试连接443或 ssl。

它继续这样做并一遍又一遍地重试。我还可以尝试与注册中心建立什么通信?

即使连接到位于美国的企业 VPN,它仍然会失败。

npm ERR! network connect ETIMEDOUT 151.101.56.162:443
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is 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 verb exit [ 1, true ]
Run Code Online (Sandbox Code Playgroud)

我怀疑是 ISP 的问题

小智 9

我在慢速互联网上遇到了类似的问题,在试验中我发现我们可以设置超时值。所以,做

npm install -timeout=9999999

对我有用,因为它将超时设置为 9999999 毫秒。


max*_*kov 1

我知道这不是真正的解决方案,但此解决方法可能会有所帮助。

经过几个小时的努力解决同样的问题后,我安装了yarn依赖项,然后使用yarn.

# 1: install yarn:
sudo npm install --global yarn

# 2: install packages from "package.json" with yarn:
yarn install
Run Code Online (Sandbox Code Playgroud)

另请参阅:“纱线使用”

yarn还面临着非常糟糕的互联网连接,但成功安装了依赖包(即使有警告):

info There appears to be trouble with your network connection. Retrying...

看来yarn是更加顽强了。