# Npm install failed with command in Dockerfile, but works with drone pipeline command

**URL:** <https://drone.discourse.group/t/npm-install-failed-with-command-in-dockerfile-but-works-with-drone-pipeline-command/10104>\
**Category:** Drone Support\
**Created:** [September 9, 2019, 12:35pm UTC](https://drone.discourse.group/t/npm-install-failed-with-command-in-dockerfile-but-works-with-drone-pipeline-command/10104 "2019-09-09T12:35:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nightlord851108](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/nightlord851108/32/5638_2.png) [@Nightlord851108](https://drone.discourse.group/u/Nightlord851108)\
**Post date:** [September 9, 2019, 12:35pm UTC](https://drone.discourse.group/t/npm-install-failed-with-command-in-dockerfile-but-works-with-drone-pipeline-command/10104/1 "2019-09-09T12:35:56Z")

</div>

Hi all,  
I’ve just built a new drone server on Kubernetes, and is trying to build a docker image of a node application through drone pipeline.

I’ve written the build commands in Dockerfile, which works fine on my local device, as following:

> FROM node:10.16.3
> 
> ADD . /app  
> WORKDIR /app
> 
> RUN npm install  
> RUN npm run build // build the vue.js static files.
> 
> RUN ls -al .  
> CMD [“node”, “server.js”]

With the following .drone.yml:

> kind: pipeline  
> type: docker
> 
> steps:  
> - name: Publish
> 
> ```
> image: plugins/docker
> settings:
> repo: my_repo
> tags: ${DRONE_COMMIT_BRANCH}.${DRONE_COMMIT:7}
> username:
> from_secret: docker_username
> password:
> from_secret: docker_password
> 
> ```
> 
> trigger:  
> branch:  
> - master  
> event:  
> - push

However, I get the following error during npm install step:

> Step 4/11 : RUN npm install  
> 124 —\> Running in cb884caee071  
> 125 npm ERR! code EAI\_AGAIN  
> 126 npm ERR! errno EAI\_AGAIN  
> 127 npm ERR! request to [https://registry.npmjs.org/@sinonjs/text-encoding/-/text-encoding-0.7.1.tgz](https://registry.npmjs.org/@sinonjs/text-encoding/-/text-encoding-0.7.1.tgz) failed, reason: getaddrinfo EAI\_AGAIN registry .npmjs.org [registry.npmjs.org:443](http://registry.npmjs.org:443)  
> 128   
> 129 npm ERR! A complete log of this run can be found in:  
> 130 npm ERR! /root/.npm/\_logs/2019-09-09T09\_06\_47\_425Z-debug.log  
> 131 The command ‘/bin/sh -c npm install’ returned a non-zero code: 1  
> 132 time=“2019-09-09T09:23:27Z” level=fatal msg=“exit status 1”

But if I move the build commands to .drone.yml, with the same node image, npm install works fine. As the following:

> kind: pipeline  
> type: docker  
> name: project
> 
> steps:  
> - name: Install node modules
> 
> ```
> image: node:10.16.3
> commands:
> - npm install
> 
> ```
> 
> - name: Build static web
> 
> ```
> image: node:10.16.3
> commands:
> - npm run build
> 
> ```
> 
> - name: Publish
> 
> ```
> image: plugins/docker
> settings:
> repo: my_repo
> tags: ${DRONE_COMMIT_BRANCH}.${DRONE_COMMIT:7}
> username:
> from_secret: docker_username
> password:
> from_secret: docker_password
> 
> ```
> 
> trigger:  
> branch:
> 
> - master  
> event:
> - push

Here’s my drone configurations:

> image: drone/drone:1.3.1  
> ports:  
> - 80:80  
> environments:  
> - DRONE\_GITLAB\_CLIENT\_ID: my\_client\_id  
> - DRONE\_GITLAB\_CLIENT\_SECRET: my\_secret,  
> - DRONE\_GITLAB\_SERVER: my\_gitlab\_domain,  
> - DRONE\_SERVER\_HOST: my\_drone\_host,  
> - DRONE\_SERVER\_PROTO: “https”  
> volumes:  
> - /data:/data  
> - /var/run/docker.sock:/var/run/docker.sock

Why “npm install” works with drone pipeline command, but doesn’t work with command in Dockerfile on the exact same drone server, while they are using the same tag of image.

---

<div class="post-metadata">

**Author:** ![reediculous456](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/reediculous456/32/2191_2.png) [@reediculous456](https://drone.discourse.group/u/reediculous456)\
**Post date:** [September 25, 2019, 6:04pm UTC](https://drone.discourse.group/t/npm-install-failed-with-command-in-dockerfile-but-works-with-drone-pipeline-command/10104/2 "2019-09-25T18:04:08Z")

</div>

I am having the same issue on drone version 0.8 with the latest plugins/docker version.

npm install succeeds in the pipeline but fails in my docker-compose file.  
This was working correctly until some time last week with no configuration changes on my end.

Any help would be much appreciated.
