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.

Permission denied missing write access to /opt/app/node_modules

See original GitHub issue

Following the instructions from the README, I cannot install additional Node packages with docker-compose exec node npm install --save <package name> due to write permissions of the ‘node’ user. If I update docker-compose.yml to set the user as ‘root’, I can again install pacakges. I’m not sure if this is the best way to solve the install permissions or not.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
BretFishercommented, Feb 25, 2019

A few options to solve this depending on what you’d like to do, in order of my preference (feedback welcome!):

  1. Fix the permissions on node_modules so they are all installed as node user, which means moving the USER Dockerfile stanza up to before npm install. This keeps your dev and prod permissions the same without reducing security (node_modules are typically the same permissions as your app files anyway.) I like this idea so much I’m going to update the repo to use this method by default, which requires moving node_modules down a directory to ensure npm has permissions to write to the pwd of node_modules. I’ll close this issue with that commit but feel free to keep commenting.
  2. Run your exec commands as root using -u root and specify the working directory to the proper /opt with: docker-compose exec -u root -w /opt/ node npm install --save <package name>
  3. Update docker-compose.yml with the user:root key to run the CMD as root for local development. I now like the above two options better.
2reactions
nielsbrilcommented, Mar 26, 2019

Dependencies can be installed again, but I still get the EBUSY: resource busy or locked error on package.json and package-lock.json due to the bind mount. Is there any way to fix this?

I’m on macOS 10.14.3 with Docker 18.09.2 and Docker Compose 1.23.2.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix the "Missing write access" error when using npm
It's a permission error, which means you don't have write access to that folder. This is how to solve it. Run this command:...
Read more >
Missing write access in mac to /usr/local/lib/node_modules
I had a similar issue when trying to install React -- issues with permissions being denied. This is where SUDO can come in...
Read more >
Fixing "Missing write access" error when using NPM
This error is generated due to improper permission. To fix this, we need to provide the proper permissions to the directory. Run this...
Read more >
How to easily fix Missing Write Access error while using NPM ...
The easiest way to fix Missing Write Access error by modifying permissions while installing a package globally using npm install command.
Read more >
How to fix missing write access to node_modules folder
Error: EACCES: permission denied, ... npm ERR! npm ERR! The operation was rejected by your operating system. Without the write access, npm will ......
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