【问题标题】:npm install errors out saying ' Error: getaddrinfo ENOTFOUND npm.lab.myorg.com'npm 安装错误说“错误:getaddrinfo ENOTFOUND npm.lab.myorg.com”
【发布时间】:2016-10-16 16:39:00
【问题描述】:

在你将我的问题标记为重复之前..我尝试了我在谷歌上能找到的所有其他东西

故事:我们正在使用 npm Enterprise 私有存储库。 Docker + Vagrant 用于构建环境设置。安装脚本包含 npm installs 引用来自私有 repo 的包。并且 npm 安装失败并出现以下错误

npm http request GET https://npm.lab.myorg.com/passport-http
npm info attempt registry request try #3 at 4:27:26 PM
npm http request GET https://npm.lab.myorg.com/verror
npm ERR! Linux 3.13.0-24-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v5.6.0
npm ERR! npm  v3.6.0
npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! syscall getaddrinfo

npm ERR! network getaddrinfo ENOTFOUND npm.lab.myorg.com npm.lab.myorg.com: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 ERR! Please include the following file with any support request:
npm ERR!     /usr/src/app/npm-debug.log

我已经尝试了网络上的所有建议

  1. 尝试重启 dns。
  2. 从 IT 部门查到是否有任何代理 没有。所以请确保npm config proxy 为空
  3. 我检查了与npm.lab.myorg.com:443 的连接性,它很好

    vagrant@dockerhost:~/git/ curl -Is https://npm.lab.myorg.com/ HTTP/1.1 200 OK Server: nginx/1.4.6 (Ubuntu) Date: Sun, 16 Oct 2016 16:26:40 GMT Content-Type: text/html; charset=utf-8 Content-Length: 36342 Connection: keep-alive X-Powered-By: Sinopia/1.4.0 X-Frame-Options: deny ETag: "180fec4dfa875dd07ebf5f43887ca234" Vary: Accept-Encoding X-Status-Cat: http://flic.kr/p/aVuVsF

更新 1;在 Dockerfile 中插入步骤 RUN curl -I -vvvv https://npm.lab.myorg.com/ 时,来自 docker 容器内部的 Curl 失败

这是输出

Step 5 : RUN curl -I -vvvv https://npm.lab.myorg.com/
 ---> Running in a677c4429ea5
* Hostname was NOT found in DNS cache
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* Could not resolve host: npm.lab.myorg.com
* Closing connection 0
curl: (6) Could not resolve host: npm.lab.myorg.com
ERROR: Service '******' failed to build: The command '/bin/sh -c curl -I -vvvv https://npm.lab.myorg.com/' returned a non-zero code: 6

从终端运行时相同的卷曲效果很好。

更新 2:下面的 docker 文件内容

FROM tools.lab.myorg.com:5000/myorg/node:0.10.40.3
LABEL description="blahhblah API" \
    version=1.0
ENV WORKDIR=/usr/src/app
WORKDIR $WORKDIR
RUN curl -I -vvvv https://www.google.co.in/
RUN mkdir -p $WORKDIR/script \
    && npm install -g privatePackage1
    && npm install -g privatePackage2
# COPY ./package.json $WORKDIR
# COPY ./script/ $WORKDIR/script/
# RUN ./script/bootstrap
COPY . $WORKDIR
CMD ["script/server"]

【问题讨论】:

    标签: node.js docker npm npm-install


    【解决方案1】:

    尝试在设置脚本中的npm install 命令之前直接运行curl -I -vvvv https://npm.lab.myorg.com/(我认为这是通过Dockerfile RUN 命令在Docker 容器上运行的?)。

    这应该会打印出一些调试信息,以显示 Docker 容器是否可以访问您的私有存储库。

    【讨论】:

    • 我猜你在发现问题时很准确。来自docker容器内部的Curl确实失败了。而来自终端外部的curl是成功的..我已经用curl详细输出更新了答案..你有什么解决方案来解释为什么这只发生在docker容器内部跨度>
    • 缩小范围总是有帮助的 :) 容器 curl 是否有任何其他 URL?
    • 另外,您使用的是哪个 Docker 容器?定制的,还是来自 Docker Hub 的?你能发布你的 Dockerfile 内容(或其中的一部分)吗?
    • 是的@ocean .. 我可以curl -I -vvvv https://www.google.co.in/ 关于docker容器,我们正在使用DockerFile创建一个自定义容器,我已经用一些内容更新了问题
    • 看看这个 s.o question stackoverflow.com/questions/24151129/… 的最佳答案你是。也许这就是问题所在?
    猜你喜欢
    • 2014-06-05
    • 1970-01-01
    • 2017-10-16
    • 2021-04-01
    • 2013-12-10
    • 2022-06-10
    • 2014-10-20
    • 2016-03-24
    相关资源
    最近更新 更多