EBUSY on npm install because of rewrite of mounted package.jsonSee original GitHub issue
Hi! Thanks for your work of gathering all this stuff in one place!
But how do you managed to make
npm install work with direct package.json mounts? I get this errors every time:
resource busy or locked, rename '/opt/package.json.3249071875' -> '/opt/package.json'
because npm tries to rewrite file from scratch rather than make atomic writes.
- Created 5 years ago
- Comments:17 (5 by maintainers)
Top GitHub Comments
This repo is just one example of using docker-compose. In my Docker for Node.js course, I cover two Solutions for designing the compose file for local development and students have thought of several other Solutions along the way.
I also talk about my two “Solutions” at DockerCon. Those slides start here in my talk.
This repo is more aligned with Solution 2 below, but you might consider Solution 1 if the package.json bind-mount issue is a blocker for you.
- Don’t move node_modules up a directory. Leave everything in the standard single dir and do a single bind-mount in the compose file.
- Before doing a
docker-compose upthe first time, we’ll need to do a
docker-compose run <app> npm installto see the node_modules that are bind-mounted to the host. This is the main disadvantage of this Solution.
- This also means on macOS/Windows that you can’t “dual develop” by sometimes using native host Node.js and sometimes using Docker-based Node.js because the binaries in node_modules (if you have them) would be incompatible. This is a disadvantage if you don’t always use docker to run this code.
- Similar to this repo’s setup, you would move node_modules and package*.json up a level in the file path, so they can be separated from host node_modules. This adds complexity to the setup but also provides the flexibility of developing with a different node_modules on the host than what is in the container.
Isn’t there way using yarn’s
--modules-folder? Assuming switch from NPM to yarn.
Then you shouldn’t need bind mounts on package*.json because all yarn commands should be feasible from project directory directly, shouldn’t?
Disclaimer: I haven’t tested it yet.