Problem when I execute npm install on docker

后端 未结 3 757
南方客
南方客 2020-12-18 08:10

Working on the same project as a colleague, when performing npm install I have the following problem, although none of my colleagues have the same problem. We all use docker

3条回答
  •  感动是毒
    2020-12-18 08:26

    Since it fails on readFileSync/openSync, this can be related to file synchronization issues between Docker and your host (Windows). It fails in /var/www which is most likely the folder which you're sharing as a volume inside the Docker container.

    As for the workaround, you can exclude a node_modules sub-folder and make it persistent.

    If you're using docker-compose.yml, mount a persistent docker volume in place of your local node_modules directory, e.g.

    ...
      volumes:
        - .:/var/www
        - node_modules:/var/www/node_modules
    

    See: Add a volume to Docker, but exclude a sub-folder

    Related GitHub issue: EINVAL: invalid argument, open 'node-sass/package.json'.

    Check also node-sass's troubleshooting page.

    Related question: npm install on laradock not working.

提交回复
热议问题