npm 安装时僵死

在 Node 上工作时,我们可能会下载各种 npm包。
有时下载过程只是挂起而不会继续前进。
我们可能还会看到与不可访问的 registry.npmjs.orgURL 相关的错误。

www. On IT Road .com

解决方案

大多数情况下(对我来说也是如此)这个错误是由于不正确的代理设置。
验证网络代理设置是否正确。

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

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

错误

通常错误日志如下所示:

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_logs18-06-18T16_50_17_569Z-debug.log
日期:2020-09-17 00:10:52 来源:oir作者:oir