错误:对https://registry.npmjs.org/yarn的网络请求失败,原因:getaddrinfo ENOTFOUND example.com example.com:8080

时间:2019-03-01 13:21:38

标签: node.js windows npm npm-install

尝试运行npm install -g "something"。但是我遇到了这个错误。

我正在使用Windows 7:

npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! network request to https://registry.npmjs.org/yarn failed, reason: 
getaddrinfo ENOTFOUND example.com example.com:8080
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\User\AppData\Roaming\npm-cache\_logs\2019-03- 
01T13_13_42_425Z-debug.log

在Chrome https://registry.npmjs.org/yarn上打开此URL时,我看到文件内容

有人可以帮我解决这个问题吗?

2 个答案:

答案 0 :(得分:0)

经过大量研究,终于找到了解决该问题的方法。

从一开始我就尝试使用npm删除代理

npm config rm proxy
npm config rm https-proxy

但是由于某种原因,它没有成功。

我在此文件中找到了代理网址 C:\Users\User\.npmrc

https-proxy=http://example.com:8080
proxy=http://example.com:8080/

手动删除这些内容可以解决此问题,并且我能够使用npm安装任何应用程序。

答案 1 :(得分:0)

在大多数情况下(以及对我而言),该错误是由于代理设置不正确造成的。验证网络代理设置正确。

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

控制台 $ npm config rm代理 $ npm config rm https-proxy

相关问题