[已解决] Npm安装挂起或时间过长

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

错误

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

E:\ngexamples\helloworld>npm install -g webpack
npm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
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
npm ERR! network This is a problem 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 ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Lokesh\AppData\Roaming\npm-cache\_logs\2018-06-18T16_50_17_569Z-debug.log

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

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

$ npm config rm proxy
$ npm config rm https-proxy

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

saigon has written 1440 articles

Leave a Reply