How to update nodeJS to the latest version

on October 31st, 2016 by Hades | No Comments »

I’ve installed nodeJS on Ubuntu with following code
sudo apt-get install nodejs-legacy npm

nodejs --version

it shows v0.10.25

Use n module from npm in order to upgrade node
sudo npm cache clean -f
sudo npm install -g n
sudo n stable

sudo ln -sf /usr/local/n/versions/node//bin/node /usr/bin/node

To upgrade to latest version (and not current stable) version, you can use

sudo n latest

To undo:

sudo apt-get install --reinstall nodejs-legacy # fix /usr/bin/node
sudo n rm 6.0.0 # replace number with version of Node that was installed
sudo npm uninstall -g n

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.