I created a dockerfile for frontend project and a docker compose project for the whole project. Running the frontend within a container works fine, however when I try with docker compose I always get the same error
Attaching to frontend_dev
frontend_dev | npm ERR! code ENOENT
frontend_dev | npm ERR! syscall open
frontend_dev | npm ERR! path /app/package.json
frontend_dev | npm ERR! errno -2
frontend_dev | npm ERR! enoent ENOENT: no such file or directory, open '/app/package.json'
frontend_dev | npm ERR! enoent This is related to npm not being able to find a file.
frontend_dev | npm ERR! enoent 
frontend_dev | 
frontend_dev | npm ERR! A complete log of this run can be found in:
frontend_dev | npm ERR!     /root/.npm/_logs/2021-01-10T22_25_43_776Z-debug.log
frontend_dev exited with code 254
The dockerfile in the frontend folder is like this
#pull base image
FROM node:13.12.0-alpine
#set working directory
WORKDIR /app
#install app dependencies
COPY package.json ./
COPY package-lock.json ./
RUN npm install 
#add frontend to docker container
COPY . ./
#launch frontend app
CMD [ "npm", "start" ]
and the docker-compose.yml is as this:
version: "3.0"
services:
  frontend:
    container_name: frontend_dev
    build: 
      context: ./frontend
      dockerfile: Dockerfile
    volumes:
      - /app/node_modules
      - .:/app
    ports:
      - 3001:3000
    stdin_open: true
    environment:
      - CHOKIDAR_USEPOLLING=true
and here is the structure of the project.project structre , docker-compose.yml is at the root of both frontend and backend, and just frontend contains the Dockerfile related to it.
