Skip to content

Instantly share code, notes, and snippets.

@pidupuis
Last active Oct 18, 2016
Embed
What would you like to do?
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