Adding/Updating NodeJS on RPi 3

For Node version 8.x use the following :

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -

For Node version 10.x use the following :

curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -

Then perform the the install with :

sudo apt-get install -y nodejs

You can then verify the versions of node and npm as follows :

node -v

npm -v

If the install has been successful the major version number for node will be 8 or 10 depending on which curl command you used above