问题描述

使用docker使用npm构建镜像的时候报错如下:

npm ERR! code EAI_AGAIN
npm ERR! errno EAI_AGAIN
npm ERR! request to https://registry.npmjs.org/grunt failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org registry.npmjs.org:443

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-08-21T09_16_04_593Z-debug.log

解决过程

  1. Dockerfile中加入RUN npm install -g cnpm --registry=http://r.cnpmjs.org,后面的npm全改为cnpm结果失败了,依然报错。
  2. 在stackoverflow找到同样问题,sudo service docker restart,成功。
    参考:https://stackoverflow.com/questions/45705555/error-installing-react-native-request-to-https-registry-npmjs-org-yallist-fai

后续问题

Error making request.
Error: connect ETIMEDOUT 54.231.120.211:443
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1161:14)

Please report this full log at https://github.com/Medium/phantomjs

显然超时了,再把解决过程1的操作加上,终于成功了。

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐