我在美国以外的地方度假,那里的连接速度很慢,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 的问题
我知道这不是真正的解决方案,但此解决方法可能会有所帮助。
经过几个小时的努力解决同样的问题后,我安装了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
是更加顽强了。