Skip to content

Instantly share code, notes, and snippets.

@edPratt
Last active December 19, 2019 21:56
Show Gist options
  • Save edPratt/b8ea809b4af655f9bdddfa9fb087b88e to your computer and use it in GitHub Desktop.
Save edPratt/b8ea809b4af655f9bdddfa9fb087b88e to your computer and use it in GitHub Desktop.
Fixing npm On Mac OS X; When npm install -g does not work

Nuke Everything node/npm related

(If you have setup another prefix)
rm -rf .npm-global

sudo rm -rf /usr/local/lib/node_modules
sudo rm -rf ~/.npm
brew uninstall node --ignore-dependencies node
rm -rf /usr/local/lib/node_modules

Install node (includes npm) from the nodejs website

To avoid using sudo with npm

sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}

@Benjamin-Lee
Copy link

Having the same issue! However, brew is giving me the following error:

brew uninstall node --ignore-dependencies --force node

Uninstalling node... (304 files, 2.3MB)
Error: Could not remove /usr/local/Cellar/node/8.2.1! Check its permissions.

@ezgcmr
Copy link

ezgcmr commented May 23, 2019

Having the same issue! However, brew is giving me the following error:

brew uninstall node --ignore-dependencies --force node

Uninstalling node... (304 files, 2.3MB)
Error: Could not remove /usr/local/Cellar/node/8.2.1! Check its permissions.

did you try with sudo ?

@JanieHuang
Copy link

Hi same error,

brew doesn't support usage of sudo anymore

@sec0ndhand
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment