Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

How can I update my nodeJS to the latest version?

I have installed nodeJS on Ubuntu with the following code
sudo apt-get install nodejs


Since I am a new user for ubuntu I also ran this code too
sudo apt-get install npm


Now when I type
 nodejs --version


It shows
v0.6.19


I checked and saw latest nodeJS version is 0.10.26

How can I update my version of nodeJS to 0.10.26?

I tried with

 sudo apt-get install <packagename>
sudo apt-get install --only-upgrade <packagename>
by

2 Answers

akshay1995
Use n module from npm in order to upgrade node

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

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

sudo n latest

Fix PATH:

sudo apt-get install --reinstall nodejs-legacy # fix /usr/bin/node

To undo:

sudo n rm 6.0.0 # replace number with version of Node that was installed
sudo npm uninstall -g n

You may need to restart your terminal to see the updated node version.
sandhya6gczb
I also recommend using nvm instead, and also removing the already installed version to avoid conflicts in the terminal

sudo apt purge nodejs npm

then install nvm and use it

Login / Signup to Answer the Question.