Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

/bin/sh: 1: react-scripts: not found in development ENV reactjs

I want to use Docker in development mode, This is my Docker file.

FROM node:18.12.1

WORKDIR /usr/src/app

COPY package*.json ./

RUN yarn install

COPY . .


EXPOSE 3000


CMD ["yarn", "start"]

and my docker-compose is:

version: '3'

services:
  mlm_frontend:
    build:
      context: .
      dockerfile: Dockerfile.dev
    volumes:
      - ./:/usr/src/app
    ports:
      - "3000:80"

I have an error /bin/sh: 1: react-scripts: not found

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

I believe this is likely because your node_modules folder is being overridden by the volume you mount with Docker Compose..

I’ll suggest you keep the node_modules from your Docker container, by telling Docker Compose to use the node_modules folder that gets created inside your Docker container, not the one from your computer. You can modify your docker-compose.yml file like this:

version: '3'
services:
  mlm_frontend:
    build:
      context: .
      dockerfile: Dockerfile.dev
    volumes:
      - ./:/usr/src/app
      - /usr/src/app/node_modules
    ports:
      - "3000:80"

Also, make sure you’re using the right Dockerfile name in your docker-compose.yml.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading