For development I almost always volume mount .:/app which would mount in the current directory (the source code) into the /app path in the container which is a general place I use to keep my source code in the container, but in your case the /app part might vary.
I don't worry about node_modules/ because at Docker build time I configure yarn to install its dependencies into /node_modules inside the Docker image instead of node_modules/ which is relative to /app.
You can do that with a .yarnrc file by putting in --modules-folder /node_modules.
In other words, I don't end up with 42 billion node dependencies on my dev box through the volume because they're never mounted.
The same strategy applies with other language package managers that install dependencies to relative folders by default (such as Composer with PHP and Mix with Elixir).
We’re a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.