Install node_modules inside Docker container and synchronize them with host

前端 未结 10 1379
旧巷少年郎
旧巷少年郎 2020-12-12 11:33

I have the problem with installing node_modules inside the Docker container and synchronize them with the host. My Docker\'s version is 18.03.1-ce, build

10条回答
  •  北海茫月
    2020-12-12 12:12

    Binding your host node_modules folder with your container node_modules is not a good practice as you mention. I have seen the solution of creating an internal volume for this folder quite often. Not doing so will cause problems during the building stage.

    I ran into this problem when I was trying to build a docker development environment for an angular app, that shows tslib errors when I was editing the files within my host folder cause my host's node_modules folder was empty (as expected).

    The cheap solution that helps me, in this case, was to use the Visual Studio Code Extension called "Remote-Containers".

    This extension will allow you to attach your Visual Studio Code to your container and edit transparently your files within your container folders. To do so, it will install an internal vscode server within your development container. For more information check this link.

    Ensure, however, that your volumes are still created in your docker-compose.yml file.

    I hope it helps :D!

提交回复
热议问题