Skip to content

Instantly share code, notes, and snippets.

@virajkulkarni14
Created June 19, 2015 14:41
Show Gist options
  • Save virajkulkarni14/22b4713af59d7a43fa52 to your computer and use it in GitHub Desktop.
Save virajkulkarni14/22b4713af59d7a43fa52 to your computer and use it in GitHub Desktop.
How to use npm global without sudo on OSX from http://www.johnpapa.net/how-to-use-npm-global-without-sudo-on-osx/
This removes, forcefully, everything in the old npm folders.
sudo rm -rf /usr/local/lib/node_modules
sudo rm -rf ~/.npm
This removes node and puts it back without npm
brew uninstall node
For advanced users, the rest of these can be run via copy and paste into terminal.
brew install node --without-npm
mkdir "${HOME}/.npm-packages"
echo NPM_PACKAGES="${HOME}/.npm-packages" >> ${HOME}/.bashrc
echo prefix=${HOME}/.npm-packages >> ${HOME}/.npmrc
curl -L https://www.npmjs.org/install.sh | sh
echo NODE_PATH=\"\$NPM_PACKAGES/lib/node_modules:\$NODE_PATH\" >> ${HOME}/.bashrc
echo PATH=\"\$NPM_PACKAGES/bin:\$PATH\" >> ${HOME}/.bashrc
echo source "~/.bashrc" >> ${HOME}/.bash_profile
source ~/.bashrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment