Permission denied missing write access to /opt/app/node_modules
See original GitHub issueFollowing 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:
- Created 5 years ago
- Comments:9 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
A few options to solve this depending on what you’d like to do, in order of my preference (feedback welcome!):
node
user, which means moving theUSER
Dockerfile stanza up to beforenpm 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 movingnode_modules
down a directory to ensurenpm
has permissions to write to the pwd ofnode_modules
. I’ll close this issue with that commit but feel free to keep commenting.-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>
docker-compose.yml
with theuser:root
key to run the CMD as root for local development. I now like the above two options better.Dependencies can be installed again, but I still get the
EBUSY: resource busy or locked
error onpackage.json
andpackage-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.