DEV Community

Discussion on: Introduction to Docker for Javascript Developers (feat Node.js and PostgreSQL)

Collapse
 
alexeagleson profile image
Alex Eagleson

You bring up a good point there is an issue here when you don't have a node_modules directory in the source. Basically the "lack of the directory" gets overwritten on the volume mount.

Here is a stackoverflow discussion about the issue:

stackoverflow.com/a/32785014

It talks about it in the context of docker-compose but the same principle should apply without compose. The syntax for adding the additional volume would be:

docker run -p 3000:8080 --name my-node-app-container --volume  ${PWD}:/usr/src/app --volume /usr/src/app/node_modules my-node-app
Enter fullscreen mode Exit fullscreen mode