sbaaaang sbaaaang - 5 months ago 53
Node.js Question

Npm Revert sudo permissions to default?

I followed this article (SECOND OPTION IN PAGE) to be able to install global modules without having to use


It works, but now i would like to revert permissions to use
again, do you have any advice or clue for this? Do i have to uninstall node and npm ?

I am on a mac osx thank you for any help.


For Option 1:

Change directories owner back to root sudo chown -R root $(npm config get prefix)/{lib/node_modules,bin,share}

For Option 2:

Change npm prefix back to default (in many cases including OSX default is /usr/local), remove folders and env variables.

Assuming you named directories and files like in manual:

npm config set prefix '/usr/local'
rm -r ~/.npm-global
rm ~/.profile

If you set NPM_CONFIG_PREFIX env variable:


Note about PATH variable: It should be fine after reboot, also you can manually set it to value without ~/.npm-global/bin section.