Unable to build docker image

+3 votes

This is the dockerfile I'm using to build the docker image:

FROM mhart/alpine-node:base-6

MAINTAINER techhadmin
COPY ./package.json src/
RUN cd src && npm install 
COPY . /src 
CMD ["npm", "start"]

But I get this error:

/bin/sh: npm: not found
The command '/bin/sh -c cd src && npm install' returned a non-zero code: 127

Any help will be appreciated..

Mar 26, 2018 in DevOps & Agile by ajs3033
• 7,300 points

edited Oct 11, 2018 by Kalgi 4,658 views

4 answers to this question.

+1 vote

See if this helps:


try not using base tags:

# If you need npm, don't use a base tag

# RUN npm install

So don't use base-6 tag and change FROM image to something like 7

FROM mhart/alpine-node:7
answered Mar 26, 2018 by Atul
• 10,230 points
+1 vote

It looks like the dev dependencies were not installed, you might have the NODE_ENV variable set to production.

answered Oct 11, 2018 by lina
• 8,220 points

edited Oct 17, 2018 by lina
0 votes

The base image that you're using is 6 and probably you need another version. try using base-7. The reason for this error is, since its using the wrong base image, it creates a wrong path. ​

answered Apr 8, 2019 by Anshul
0 votes

There is another Cheap workaround(not suggested). You can remove the lines that create errors from the Dockerfile and execute those commands manually. But of course this is not recommended, the entire point of Dockerfile is undermined.

answered Apr 8, 2019 by Anshul

Related Questions In DevOps & Agile

0 votes
1 answer
0 votes
1 answer

unable to build .Net project using NUGet

you just need the developer pack for ...READ MORE

answered Apr 3, 2018 in DevOps & Agile by ajs3033
• 7,300 points
0 votes
1 answer

Error: Unable to access elasticsearch in docker for windows

This is simple, just follow the below ...READ MORE

answered Sep 3, 2018 in DevOps & Agile by Sophie may
• 10,590 points
0 votes
1 answer
+2 votes
1 answer
+2 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 58,100 points
0 votes
1 answer

Is it possible to preserve local ivy repository in Bluemix BUILD & DEPLOY?

You're right--the pipeline spins up a new ...READ MORE

answered Jul 19, 2018 in DevOps & Agile by Atul
• 10,230 points
+5 votes
2 answers

How to program and get the Digital Ocean ID of the current Droplet from within the Droplet?

You can run curl within the ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by Atul
• 10,230 points
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP