Docker: npm not found

Issue

I have the following Dockerfile:

FROM ubuntu
USER root
RUN apt-get update && apt-get install curl -y
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash -
RUN apt-get update && apt-get upgrade -y && apt-get install nodejs -y
RUN mkdir /opt/public
RUN mkdir /opt/bin
ADD public /opt/public
ADD bin /opt/bin
RUN ls -lah /opt/bin
RUN ls -lah /opt/public
ADD run.sh /bin/run.sh
RUN chmod +x /bin/run.sh
RUN cd /opt/bin && npm install
CMD ["/bin/run.sh"]

When I build the Container, I get this eror:

/bin/sh: 1: npm: not found

What is the problem? Could you please help me?

Solution

Try installing npm separately while building the image:

RUN apt-get update && apt-get upgrade -y && \
    apt-get install -y nodejs \
    npm                       # note this one

Answered By – Yury Fedorov

Answer Checked By – Senaida (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.