This post will help you to install Node.Js version 6, 7 and 8 on our ubuntu families. First, we have downloaded the GPG Signing Key from Node source for the repository.  Otherwise, you may get NO_PUBKEY errors with apt-get update:

curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | sudo apt-key add -

Then run the command apt-get update,

sudo apt-get update


And then, for node 6, run the below command,

$ sudo curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
$ sudo apt-get update
$ sudo  apt-get install -y nodejs 

For node 7, run the below command,

$ sudo  curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
$ sudo apt-get update
$ sudo  apt-get install -y nodejs 

For node 8, run the below command,

$ sudo curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
$ sudo apt-get update
$ sudo apt-get install -y nodejs