繁体   English   中英

NPM 安装总是无法随机获取 Docker 容器中的 NPM 注册表

[英]NPM install always fails to fetch NPM registry in Docker container at random times

我们已经在 Node.js Web 应用程序上设置了持续集成/部署。 问题是,当管道在 CI 服务器 (GitLab CI) 上的 docker 容器中运行测试时,npm install 会随机失败。 容器使用 node v5.0.0 和 npm v3.3.6。 NPM 安装的输出是:

npm info retry will retry, error on last attempt: Error: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
npm info retry will retry, error on last attempt: Error: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
npm info attempt registry request try #3 at 4:39:19 PM
npm http fetch GET https://registry.npmjs.org/commander/-/commander-2.8.1.tgz
npm info attempt registry request try #3 at 4:39:19 PM
npm http fetch GET https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz
npm ERR! fetch failed https://registry.npmjs.org/commander/-/commander-2.8.1.tgz
npm WARN retry will retry, error on last attempt: Error: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
npm ERR! fetch failed https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz
npm WARN retry will retry, error on last attempt: Error: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
npm info retry fetch attempt 3 at 4:40:27 PM
npm info attempt registry request try #1 at 4:40:27 PM
npm http fetch GET https://registry.npmjs.org/commander/-/commander-2.8.1.tgz
npm info retry fetch attempt 3 at 4:40:27 PM
npm info attempt registry request try #1 at 4:40:27 PM
npm http fetch GET https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz
npm info retry will retry, error on last attempt: Error: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
npm info retry will retry, error on last attempt: Error: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
npm info attempt registry request try #2 at 4:40:45 PM
npm http fetch GET https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz
npm info attempt registry request try #2 at 4:40:45 PM
npm http fetch GET https://registry.npmjs.org/commander/-/commander-2.8.1.tgz
npm info retry will retry, error on last attempt: Error: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
npm info retry will retry, error on last attempt: Error: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
npm info attempt registry request try #3 at 4:41:53 PM
npm http fetch GET https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz
npm info attempt registry request try #3 at 4:41:53 PM
npm http fetch GET https://registry.npmjs.org/commander/-/commander-2.8.1.tgz
npm ERR! fetch failed https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz
npm ERR! fetch failed https://registry.npmjs.org/commander/-/commander-2.8.1.tgz
npm ERR! Linux 3.16.0-4-amd64
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v5.0.0
npm ERR! npm  v3.3.6
npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! syscall getaddrinfo

npm ERR! network getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is 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 无法获取 3 次中的 2 次,所以这似乎是一个网络问题,但是 CI 服务器正在 Compute Engine 上运行(我相信 Google 和 NPM 注册表连接......)。 所以我只是尝试重新启动我的 Docker 服务,但它也不起作用。

有什么想法吗? 提前致谢!

编辑:今天(2016 年 10 月 21 日)发生了大规模的 DNS 中断,这可能是问题的根源吗? 它还可以解释为什么其他项目的其他构建在不久之后的部署步骤中失败了。 https://www.wired.com/2016/10/internet-outage-ddos-dns-dyn/

事实证明,今天发生了大规模的 DNS 中断,导致我的构建失败。 https://www.wired.com/2016/10/internet-outage-ddos-dns-dyn/

检查 VPN 是否开启。 在大多数情况下,VPN 会导致此问题。 断开与 VPN 的连接,然后再试一次,它会起作用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM