When I try to install something (gulp, sass, webpack, etc.) globally with sudo npm install packagename -g
I always get these errors:
node-pre-gyp WARN Hit error EACCES: permission denied, mkdir '/usr/local/lib/node_modules/webpack/node_modules/fsevents/lib'
gyp WARN EACCES user "root" does not have permission to access the dev dir "/Users/erik/.node-gyp/11.11.0"
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/webpack/node_modules/fsevents/.node-gyp'
And a whole lot more similar errors.
I have tried fixing disk permissions with Disk Repair. I have completely uninstalled and reinstalled Node. I have tried other answers on stack overflow, such as:
sudo chown -R $(whoami) ~/.npm
and
sudo chown -R $(whoami) /usr/local/lib/node_modules
but this has not helped.
How do I fix the permissions so that I can install global npm packages again?
I'm running OS X Mojave with Node 11.11.0
--unsafe-perm
option, for example when installing sqlite3sudo npm install --unsafe-perm -g sqlite3
. Then it worked, but I don't know the underlying problem. – Roland Starke