【问题标题】:NPM install failing with 502 errorNPM 安装失败并出现 502 错误
【发布时间】:2016-11-08 04:53:23
【问题描述】:

这是一个相当模糊的问题。我有一个 Angular 应用程序,它将通过 Codeship for CI 运行。但是,当需要在 Codeship 框上运行 npm install 时,npm 会返回

-npm ERR! fetch failed https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-2.4.1.tgz
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 502
\npm ERR! fetch failed https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-2.4.1.tgz
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 502
\npm ERR! fetch failed https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-2.4.1.tgz
npm ERR! Linux 4.2.0-38-generic
npm ERR! argv "/home/rof/.nvm/versions/node/v4.1.1/bin/node" "/home/rof/.nvm/versions/node/v4.1.1/bin/npm" "install"
npm ERR! node v4.1.1
npm ERR! npm  v2.14.4

npm ERR! fetch failed with status code 502

这很奇怪,因为 npm install 在我的盒子上工作得很好。我的第一直觉是它一定是 NPM 存储库的问题,所以我抓住了包的 url (https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-2.4.1.tgz) 并将其放入新的 Chrome 选项卡中。果然,档案几乎立即下载。我对此感到困惑,所以我再次尝试了 Codeship 构建,但得到了相同的结果。我决定通过 SSH 连接到 Codeship 框,看看是否可以访问它。我跑了

curl https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-2.4.1.tgz

正如我所料,我收到了 502 错误。但是,当我从我的机器上的终端运行相同的命令时,我得到了相同的结果,即使 npm install 对我来说运行得很好。我找不到其他人遇到此类问题,并且 502 似乎是 NPM 注册表返回的非常罕见的代码。有什么想法吗?

【问题讨论】:

  • 问题是关于现在在 npm 注册服务器上发生的问题。 @andrey Romashin 的答案链接到正在进行的讨论,足以了解情况,但不应鼓励未来的讨论。

标签: node.js curl npm codeship


【解决方案1】:

这是 registry.npmjs.org 在某些地区的问题。

这里是问题: https://github.com/npm/npm/issues/13284

【讨论】:

    【解决方案2】:

    我在 AWS 上运行的 Ubuntu 14 上通过 npm install 看到了同样的问题

    curl https://registry.npmjs.org/combine-lists/-/combine-lists-1.0.0.tgz
    

    从 ubuntu 服务器返回 502 Bad Gateway,但在本地客户端可以正常工作

    在 NPM 有一个未解决的问题:

    https://github.com/npm/npm/issues/13284

    【讨论】:

      【解决方案3】:

      尝试在.npmrc 文件中保留一个注册表,其中只有一个有效。 注册表的顺序也很重要。也尝试设置:

      • npm config delete proxy
      • npm config delete https-proxy

      清理终端内的代理。

      【讨论】:

        【解决方案4】:

        NPM 刚刚承认了这个问题,他们正在努力解决这个问题。您可以通过以下链接跟踪状态。

        http://status.npmjs.org

        【讨论】:

          【解决方案5】:

          在 npm 上发布我的包时出现此错误。把头撞在墙上几个小时后,我意识到我正在使用移动热点。我切换到 wifi,然后在 npm 上有我的包!

          【讨论】:

          • 移动热点跟它有什么关系?我一直在移动热点上上网,但我没有 WiFi。有什么办法可以解决这个问题?
          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2016-02-27
          • 2017-08-28
          • 1970-01-01
          • 2021-07-13
          • 1970-01-01
          • 2021-07-31
          • 1970-01-01
          相关资源
          最近更新 更多