原文: https://howtodoinjava.com/angular/npm-install-hung/

在使用 Node 时,您可能正在下载各种npm包。 有时下载过程只是挂起而无法继续进行。 您可能还会看到与不可访问的registry.npmjs.org URL 相关的错误。

错误

通常,错误日志如下所示:

  1. E:\ngexamples\helloworld>npm install -g webpack
  2. npm ERR! code ETIMEDOUT
  3. npm ERR! errno ETIMEDOUT
  4. npm ERR! network request to https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz failed, reason: connect ETIMEDOUT 104.18.95.96:443
  5. npm ERR! network This is a problem related to network connectivity.
  6. npm ERR! network In most cases you are behind a proxy or have bad network settings.
  7. npm ERR! network
  8. npm ERR! network If you are behind a proxy, please make sure that the
  9. npm ERR! network 'proxy' config is set properly. See: 'npm help config'
  10. npm ERR! A complete log of this run can be found in:
  11. npm ERR! C:\Users\Lokesh\AppData\Roaming\npm-cache\_logs\2018-06-18T16_50_17_569Z-debug.log

解决方案

大多数情况下(也是我自己),此错误是由于代理设置不正确引起的。 验证网络代理设置正确。

否则,请尝试使用以下命令删除代理设置,然后重试。

  1. $ npm config rm proxy
  2. $ npm config rm https-proxy

希望以上命令也将为您解决此错误。

学习愉快!