I'm installing the current LTS release of nodejs and npm, which is v8.9.1 and 5.5.1 on Ubuntu 16.04 LTS
- Download the setup script: https://deb.nodesource.com/setup_8.x and make sure you understand what it does before continuing...
- Chmod +x the setup script to make it an executable. Mine is called setup_8.x and I have renamed it setup_8.x.sh
- Run the script with sudo, it will add another repository to your sources.list.d and update apt's cache.
- Install the nodejs packages as the script states using:
sudo apt-get install nodejs
- Type nodejs --version to get your nodejs version and type npm -v to get your npm version.
If all went well it should be similar to mine.
Note: I recommend to never use Curl or Wget to automagically download and run a script. It's a bad idea since you do not know what the script will do. So please make sure you understand what you're doing before running a script of the Internet ;)