title: how to fix npm install failed in Docker
body: <p>I am trying to dockerize my small reactjs app.</p>
  
  <p>This is my <code>Dockerfile</code></p>
  
  <pre><code>FROM node
  
  WORKDIR /usr/src/app
  
  COPY package.json .
  
  COPY . .
  
  EXPOSE 8080
  
  RUN npm install // gives the error when executing this step
  RUN npm install react-scripts@3.4.1 -g --silent
  
  # start app
  CMD ["npm", "start"]
  </code></pre>
  
  <p>And this is my <code>package.json</code></p>
  
  <pre><code>{
    "name": "cyberhr",
    "version": "0.1.0",
    "private": true,
    "dependencies": {
      "3d-force-graph": "^1.60.11",
      "@tensorflow/tfjs": "^1.7.2",
      "@tensorflow/tfjs-tsne": "^0.2.0",
      "d3-dsv": "^1.2.0",
      "mdbreact": "4.25.3",
      "react": "^16.12.0",
      "react-dom": "^16.12.0",
      "react-force-graph": "^1.32.1",
      "react-router-dom": "^5.1.2",
      "react-scripts": "3.4.0",
      "tsne-js": "^1.0.3"
    },
    "scripts": {
      "start": "react-scripts start",
      "build": "react-scripts build",
      "test": "react-scripts test --env=jsdom"
    },
    "devDependencies": {
      "renamer": "^1.0.0",
      "rimraf": "^2.6.2"
    },
    "browserslist": [
      "&gt;0.2%",
      "not dead",
      "not ie &lt;= 11",
      "not op_mini all"
    ]
  }
  </code></pre>
  
  <p>But it fails at the <code>npm install</code> step and gives the following error</p>
  
  <blockquote>
    <p>Service 'frontend' failed to build: The command '/bin/sh -c npm install' returned a non-zero code: 244</p>
  </blockquote>
  
  <p>Here is a screenshot of the error in detail</p>
  
  <p><a href="https://i.stack.imgur.com/Zaswe.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Zaswe.png" alt="enter image description here"></a></p>
  
  <p>Can someone please help me?</p>