Skip to content

Instantly share code, notes, and snippets.

@pidupuis
Last active October 18, 2016 07:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pidupuis/8bedbd5aa06fdaeea59181e65f13b182 to your computer and use it in GitHub Desktop.
Save pidupuis/8bedbd5aa06fdaeea59181e65f13b182 to your computer and use it in GitHub Desktop.
How to clean a messy npm installation

## NPM installation

To install or upgrade nodejs and npm properly, run:

# Nodejs
## On Ubuntu
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get -y install nodejs

## On CentOS
curl -sL https://rpm.nodesource.com/setup_4.x | sudo -E bash -
sudo yum -y install nodejs
# Npm
mkdir ~/npm
npm config set prefix ~/npm
npm config set progress false
npm install -g npm@latest

If your installation is messy, here is a command to completely uninstall nodejs and npm:

sudo rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/{npm*,node*,man1/node*} ~/{.npm,.node-gyp} /usr/bin/{,X11/}{npm*,node*} /usr/{share,include,lib}/{npm*,node*} /usr/share/man/man1/node*

⚠️ This could have heavy impact on your other projects or some of your softwares!

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