Upgrade node.js version after upgrading ubuntu 14 one-click to Ubuntu 16

I just upgraded a one-click node.js ubuntu 14.04 image to ubuntu 16.04.

The node version is v4.2.1 and the binary is located at /usr/local/bin/node. However, Ubuntu 16 comes with node v4.6.0. I discovered that there is a /usr/bin/node which is v4.6.0 on my image.

How can I remove the old node version and use the newer node version that comes with Ubuntu 16.05?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi xMudrii,

Your method does not work. The Ubuntu node.js version is upgraded to 6.8 but the older node.js remains. I think the cause of the problem lies with the PATH variable. The PATH variable is set such that the older node.js version has priority over the newer one.

I posted a new question as a follow-up to this question

I have a new problem. Would you know how to downgrade node v6.8 back to node v4.6?

You can go even without removing old node, just by adding 6.x repository and updating. If you want to remove it you can do it by executing

  1. sudo apt-get remove nodejs

This is fully optional step, as you can get it working without removing. Basically, we will install it using PPA method.

Download repo installer by executing:

  1. curl -sL -o

After it downloads, you can inspect it if you want with any text editor:

  1. nano

If it’s OK, run it:

  1. sudo bash

Let it finish. Now you are ready to install latest Node.js. If you didn’t removed Node.js, just run:

  1. sudo apt-get upgrade
apt-get upgrade
root@node-512mb-nyc1-01:~# sudo apt-get -y upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following package was automatically installed and is no longer required:
Use 'sudo apt autoremove' to remove it.
The following packages will be upgraded:
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 10.1 MB of archives.
After this operation, 37.5 MB of additional disk space will be used.

As you can see, it will upgrade your Node.js to latest. Yet, if you removed it in first step, install it with:

  1. sudo apt-get -y install nodejs

That is it! You can now verify version of Node.js with:

  1. node -v

At time of writing this it should output:

node -v

You can also verify npm version with:

  1. npm -v

At time of writing it is:

npm -v