Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing node_modules after npm install inside Docker

I am running Docker with Docker Machine on Mac. I successfully set up some containers and ran npm install inside them, as explained here. This installs the node_modules inside the image and inside the container, but they are not available on the host, i.e. my IDE complains about missing node_modules.

Am I missing something? What is the best way to run npm install inside the container but be able to do development (with these dependencies) on the host?

From my docker-compose.yml:

  volumes:
    - /Users/andre/IdeaProjects/app:/home/app
    - /home/app/node_modules
like image 883
André Avatar asked Mar 25 '26 21:03

André


1 Answers

Since you are using boot2docker, only Max host folder /Users/ is mounted and accessible from the boot2docker host.

That means you would need to map /home/app/node_modules to a Mac host path starting with /Users, to see said modules on your Mac host.

volumes:
    - /Users/andre/IdeaProjects/app:/home/app
    - /Users/andre/node_modules:/home/app/node_modules
like image 180
VonC Avatar answered Mar 28 '26 18:03

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!