2

Within my docker file, when it comes to installing npm packages, I get the error:

npm WARN athena@1.0.0 No description
npm WARN athena@1.0.0 No repository field.

npm ERR! code EAI_AGAIN
npm ERR! errno EAI_AGAIN
npm ERR! request to https://registry.npmjs.org/jsesc/-/jsesc-2.5.1.tgz 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-06-05T13_33_53_797Z-debug.log

My Dockerfile is:

FROM node:10.3-alpine
COPY . /app
WORKDIR /app
RUN npm install
EXPOSE 8080
ENTRYPOINT [ "npm run start:dev" ]

Searching online, I came across this link on github, however, adding the instruction as per Jkugyiya's post didn't resolve. I wondered whether I did the correct thing of adding the line to my /etc/host file.

My question is how can I get Docker to install NPM packages within the image.

Thanks

EDIT: As per @Capricorn's request, the dev environment details are: Ubuntu 18.04 Docker version 17.12

EDIT2: Running ping registry.npmjs.org gives an endless stream of messages similar to below. While all packets were transmitted & received, however, notice the time delays:

64 bytes from registry.npmjs.org (151.101.72.162): icmp_seq=3 ttl=53 time=333 ms
64 bytes from registry.npmjs.org (151.101.72.162): icmp_seq=4 ttl=53 time=273 ms
64 bytes from registry.npmjs.org (151.101.72.162): icmp_seq=5 ttl=53 time=317 ms
64 bytes from registry.npmjs.org (151.101.72.162): icmp_seq=6 ttl=53 time=253 ms
64 bytes from registry.npmjs.org (151.101.72.162): icmp_seq=7 ttl=53 time=301 ms
64 bytes from registry.npmjs.org (151.101.72.162): icmp_seq=8 ttl=53 time=337 ms
...
Kayote
  • 14,579
  • 25
  • 85
  • 144
  • As this problem is probably related to your dev environment, additional details about OS, docker version, how docker is installed might be interesting. Furthermore, do you have any docker container running that can access the internet? – Capricorn Jun 05 '18 at 14:37
  • @Capricorn, Ubuntu 18.04, Docker version 17.12, docker can access the internet just fine. It downloaded the node:10.3-alpine off dockerhub. I can also successfully do search. – Kayote Jun 05 '18 at 14:42
  • 1
    try adding `RUN ping registry.npmjs.org` to your dockerfile before you do the `npm install` . That should tell you if it can resolve the dns entry and route out. – Arcath Jun 05 '18 at 19:31
  • @Arcath I got the error: `ping: bad address 'registry.npmjs.org'` – Kayote Jun 06 '18 at 09:38
  • It looks like your docker container can't get onto the internet. – Arcath Jun 06 '18 at 11:38
  • I got it working. Once I installed node locally on my machine, the image was built successfully. I am not sure I understand why, considering docker is containerised & node is installed initially, why was node required on my machine to install the packages... – Kayote Jun 06 '18 at 11:48
  • 1
    how did you fix this? – Muzi Jack Jun 07 '19 at 10:18
  • @bhargav-rao how do you recommend linking the same answer to this duplicate probelm? – vegasbrianc Jul 30 '19 at 11:50

0 Answers0