It's recommended to install the current active Node.js LTS.
The following command would install Node.js 6.x.
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -sudo apt-get install -y nodejs
NOTE: Version 6.x LTS ends on April 2019.
Check your Node.js version
node -v# Output: v6.11.2
To install Node.js 8, use the following command.
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -sudo apt-get install -y nodejs