首页 > 解决方案 > 错误:对 https://registry.npmjs.org/yarn 的网络请求失败,原因:getaddrinfo ENOTFOUND example.com example.com:8080

问题描述

试图运行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 时,我看到了文件内容

谁能帮我解决这个问题?

标签: node.jswindowsnpmnpm-install

解决方案


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

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

npm config rm proxy
npm config rm https-proxy

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

我在这个文件中找到了代理 url C:\Users\User\.npmrc

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

手动删除这些解决了这个问题,我可以使用 npm 安装任何应用程序。


推荐阅读