Getting no such file package.json when running npm install

I am running Docker on Windows 10 and when I run docker-compose up -d I get this errror but I don’t know why.

npm WARN saveError ENOENT: no such file or directory, open '/var/www/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/var/www/package.json'
npm WARN www No description
npm WARN www No repository field.
npm WARN www No README data
npm WARN www No license field.

Here is my docker-compose.yaml file

version: '3'
services:

  # Nginx client app server
  nginx-client:
    container_name: nginx-client
    build:
        context: ./docker/nginx-client
        dockerfile: Dockerfile
    restart: unless-stopped
    ports:
      - 28874:3000
    volumes:
        - ./client:/var/www
    networks:
      - app-network


# Networks
networks:
  app-network:
    driver: bridge

And here is my Dockerfile

FROM node:12
WORKDIR /var/www
RUN npm install
CMD ["npm", "run", "serve"]

I found the solution to my problem. It turned out that the binding of volumes doesn’t take place until the container is fully created. So the files that I THOUGHT were there were not actually there yet. So I could do something like this

COPY ./client/package*.json ./
RUN npm install
1 Like