【问题标题】:Error: network request to https://registry.npmjs.org/yarn failed, reason: getaddrinfo ENOTFOUND example.com example.com:8080错误:对 https://registry.npmjs.org/yarn 的网络请求失败,原因:getaddrinfo ENOTFOUND example.com example.com:8080
【发布时间】:2019-07-23 12:59:09
【问题描述】:

尝试运行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.js windows npm npm-install


    【解决方案1】:

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

    从一开始我就尝试使用 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 安装任何应用程序。

    【讨论】:

      【解决方案2】:

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

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

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

      【讨论】:

        猜你喜欢
        • 2019-11-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-09-29
        • 2017-01-28
        • 2021-02-03
        • 2018-07-04
        • 2019-07-03
        相关资源
        最近更新 更多