Here's a quick tutorial how to do a fresh install of the latest lts Node.js version on Ubuntu via Node version manager (
nvm). This tutorial also covers removing any old Node.js installations. Installing via
nvm is the recommended solution as you can manage different versions and root access is no longer required to install global node modules.
Remove all node packages (note that npm should have automatically be removed but you can run the command just to be safe):
sudo apt-get remove nodejs sudo apt-get remove npm
Cleanup node modules:
rm -rf ~/.npm sudo rm -rf /usr/local/lib/node_modules/You would now also need to delete any broken symlinks under
Remove any existing
rm -rf ~/.nvm
Follow the installation instructions here: https://github.com/creationix/nvm
nvm help nvm install --lts nvm alias default node # set the default version otherwise node is not available to a shell session node --version # v4.4.7 npm --version # 2.15.8And voila, you have a freshly minted version of Node.js :). Read on for more info on installing global modules and some useful npm commands.
I personally need the following packages installed globally as well:
npm install -g grunt grunt-cli npm install -g gulp npm install -g mocha npm install -g browserify npm install -g envify npm install -g clean-css uglifyjs nodemon node-sass npm install -g forever
# List all installed packages npm ls -g # update a given package npm update -g mocha # find out all outdated packages npm outdated -g
Back to the article list.
Subscribe to get articles as they are published direct to your inbox!