The command '/bin/sh -c npm install --silent' returned a non-zero code: 254

Viewed 2616

When m trying to craete image of react app with dockerenter image description herefile its saying...

    The command '/bin/sh -c npm install --silent' returned a non-zero code: 254

Here is my dockerfile

# Pull official base image
FROM node:13.12.0-alpine

# Set working directory
WORKDIR /app

# Add `/app/node_modules/.bin` to $PATH
ENV PATH /app/node_modules/.bin:$PATH

# install app dependencies
COPY package.json ./
COPY package-lock.json ./
RUN npm install --silent
RUN npm install react-scripts@3.4.1 -g --silent

# add app
COPY . ./

# start app
CMD ["npm", "start"]
2 Answers

Make sure that npm is reading package.json from the place you're copying it to.

This basically happens when something is broken while docker tries to install JS packages. As the error code "254" stands for all types of installation failures, the only way to get the specific issue is by running the "install" or "ci" command without --silent.

Related