Skip to content

Instantly share code, notes, and snippets.

@trungnghia112
Forked from DanHerbert/fix-homebrew-npm.md
Last active June 28, 2016 04:23
Show Gist options
  • Save trungnghia112/56993e87e0ad9476496895ae25a31f66 to your computer and use it in GitHub Desktop.
Save trungnghia112/56993e87e0ad9476496895ae25a31f66 to your computer and use it in GitHub Desktop.
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

sudo rm -rf /usr/local/lib/node_modules
sudo rm -rf ~/.npm

brew uninstall node

brew install node

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