question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

EBUSY on npm install because of rewrite of mounted package.json

See 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.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:4
  • Comments:17 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
BretFishercommented, Feb 11, 2020

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.

Solution 1:

  • 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 up the first time, we’ll need to do a docker-compose run <app> npm install to 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.

Solution 2:

  • 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.
0reactions
petrprikrylcommented, Aug 3, 2020

Isn’t there way using yarn’s --modules-folder? Assuming switch from NPM to yarn. https://stackoverflow.com/a/53998408/1763888 https://classic.yarnpkg.com/en/docs/cli/install#toc-yarn-install-modules-folder

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

npm install error code EBUSY errono -4082 - Stack Overflow
I found that is because I npm run in a terminal and npm install in another terminal. The file was occupied. I just...
Read more >
package-lock.json - npm Docs
Describe a single representation of a dependency tree such that teammates, deployments, and continuous integration are guaranteed to install exactly the same ...
Read more >
npm ERR! code EBUSY - Reddit
I'm running Windows 11 Pro. PS C:\_offline\BGIO Tutorial\testboard3\TestBoardGame> npm install npm WARN config global `--global`, `--local` are ...
Read more >
The Complete Guide to package-lock.json - Medium
Here, foo is installed with version 2.3.0 [major minor patch] . The caret symbol tells something ... Why / When does npm install...
Read more >
How To Use Node.js Modules with npm and package.json
By having Node.js installed you will also have npm installed; this tutorial uses version 8.11.0. Step 1 — Creating a package.json File.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found