在使用 Node 时,您可能正在下载各种npm包。 有时下载过程只是挂起而无法继续进行。 您可能还会看到与不可访问的registry.npmjs.org URL 相关的错误。
错误
通常,错误日志如下所示:
E:\ngexamples\helloworld>npm install -g webpacknpm ERR! code ETIMEDOUTnpm ERR! errno ETIMEDOUTnpm 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:443npm 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! networknpm ERR! network If you are behind a proxy, please make sure that thenpm 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
希望以上命令也将为您解决此错误。
学习愉快!
