docker-compose fails to start with npm ERR! enoent ENOENT: no such file or directory, open '/usr/src/app/package.json'

前端 未结 1 1262
傲寒
傲寒 2021-01-13 15:14

I built an image from a docker file to run node and copy in a simple node express app which works perfectly. The image builds I can run a container and bash in and the local

相关标签:
1条回答
  • 2021-01-13 15:41

    When your docker-compose.yml says

    volumes:
      - ./:/usr/src/app
    

    it hides everything that gets done in the Dockerfile and replaces it with the current directory. If your current directory doesn't have the package.json file (maybe you moved everything Docker-related into a subdirectory) it will cause the error you see.

    Personally I would just remove these two lines, develop my application locally (without Docker, using the per-project node_modules directory for isolation), and only build the Docker image when I'm actually ready to deploy it.

    0 讨论(0)
提交回复
热议问题