我在美国以外的地方度假,那里连接速度很慢,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
我已尝试将注册表设置为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 ]
我怀疑这是ISP的问题
答案 0 :(得分:7)
在慢速的互联网和实验中,我遇到了类似的问题,我发现我们可以设置超时值。 所以,做
npm install -timeout=9999999
为我工作,因为它将超时设置为9999999毫秒。
答案 1 :(得分:-1)
我知道这不是一个真正的解决方案,但是这种解决方法可能会有所帮助。
经过数小时的相同问题的努力,我安装了yarn
,然后使用yarn
安装了依赖项。
# 1: install yarn:
sudo npm install --global yarn
# 2: install packages from "package.json" with yarn:
yarn install
另请参阅:"Yarn usage"。
yarn
也面临着非常糟糕的Internet连接,但是成功安装了相关软件包(即使出现警告):
info There appears to be trouble with your network connection. Retrying...
yarn
似乎更加顽固。