Install nodejs 8.x LTS version in Ubuntu 18.04 LTS Bionic Beaver

 cd ~
 curl -sL https://deb.nodesource.com/setup_8.x -o nodesource_setup.sh
 sudo bash nodesource_setup.sh
 sudo apt-get install nodejs
 nodejs -v


As NodeJS 10.x LTS version is released, use below commands to install the same

 cd ~
 curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
 sudo apt-get install -y nodejs
 nodejs -v



If you already have NodeJS 8.x LTS version is installed, use below commands for upgrading to NodeJS 10.x

 cd ~
 curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
 sudo apt-get update
 nodejs -v