Skip to content

Instantly share code, notes, and snippets.

@twistedstream
Last active October 10, 2023 11:48
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save twistedstream/67faee81e36f86d45581 to your computer and use it in GitHub Desktop.
Save twistedstream/67faee81e36f86d45581 to your computer and use it in GitHub Desktop.
How to reinstall Node + NPM via NVM

Remove existing Node/NPM

If you installed Node directly using Homebrew, then uninstall it by running:

brew uninstall node

Now, clean up the rest:

sudo
rm -rf /usr/local/lib/node
rm -rf /usr/local/lib/node_modules
rm -rf /usr/local/include/node
rm -rf /usr/local/include/node_modules
rm /usr/local/bin/npm
rm /usr/local/lib/dtrace/node.d
rm -rf ~/.npm
rm -rf ~/.node-gyp
rm /opt/local/bin/node
rm /opt/local/include/node
rm -rf /opt/local/lib/node_modules

Install Node/NPM via Homebrew

It's recommended to install Node using nvm, which can be done via Homebrew by:

# install nvm
brew update
brew install nvm
# Follow the post install instructions to include nvm in your startup scripts.  I usually do the following:
echo 'export NVM_DIR=~/.nvm' >> .bash_profile
echo 'source $(brew --prefix nvm)/nvm.sh' >> .bash_profile
# install your favorite version of node and set it as the default
nvm install 0.12
nvm alias default 0.12

Source: http://stackoverflow.com/a/11178106

@taylorjdawson
Copy link

will this blast all global packages?

@twistedstream
Copy link
Author

@taylorjdawson: Yes AFAIK

@mmimpen
Copy link

mmimpen commented Jan 31, 2022

Thanks, works like a charm!

@prmichaelsen
Copy link

good meme but who installs 0.12

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