How to install the last Node.js version on Ubuntu

The easy way and which I will explain is to use PPA (personal package archive), is a repository maintained by NodeSource, they maintain the latest Node.js packages. Also allow select between the stable version v4.x which has long term support or the version v6.x that is the current last version and constantly receives updates.

Add the new source to out repositories, in this case; we select the version v6.x.

sudo apt-get install python-software-properties
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -

The last step is to install Node.js

sudo apt-get install nodejs

If you already have an old Node.js version in your system, you can uninstall it with this command:

sudo apt-get auto-remove