I'm trying to figure out how to get the permissions to work for me with my node_modules directory. Here's the problem...
user1
goes to a folder with a package.json and runs npm install
resulting in a node_modules
directory with the owner and group user1
.
user2
then goes to that folder (it's a shared folder) and tries running something like npm install --save some_dep
, but they don't have permissions on this directory so it fails.
Okay, that's fine.. so I chown -R
the node_modules to be a shared group which both users are in.
Now user2
can run his command successfully resulting in a folder node_modules/some_dep
. But now user1
doesn't have access to this folder.
So I try using a setgid permission on the node_modules
directory. Something like chmod -R g+s node_modules
. The result is exactly the same as before - when a user runs a NPM command the resulting directory gets the wrong group and permissions.
So I tried using ACLs, but the result is again the same.. the directories resulting from a user running an NPM command will not respect the permissions of the host folder.
Maybe this has something to do with how NPM dependencies are built. Maybe they are built elsewhere and then moved?
Is there any way to set permissions that are effective for that directory and all future subdirectories in such a way that I can make this work?
I could just run everything as root all the time... but this is clearly not ideal.