No access permission error with npm global install on docker image

The problem is because while NPM runs globally installed module scripts as the nobody user, which kinds of makes sense, recent versions of NPM started setting the file permissions for node modules to root. As a result module scripts are no longer allowed to create files and directories in their module.

See discussion in NPM issue #3849, for some references.

A simple workaround, which makes sense in a docker environment, is to set the NPM default global user back to root, like so:

npm -g config set user root

After which you shouldn’t have any more EACCES errors.

Leave a Comment