If Node install script doesn't work for you (it didn't for me), here's the solution to update Node Js in Debian Jessie, taken from the reply from Thomas Ward at askubuntu.com (Thanks, buddy!).
1.- Create a new file: /etc/apt/sources.list.d/nodesource.list
You'll need to create this file with sudo, but when you create the file, put this inside it:
deb https://deb.nodesource.com/node_9.x jessie main
deb-src https://deb.nodesource.com/node_9.x jessie main
Then, save the file. (replace node_9.x with the desired version)
2.- Download the GPG Signing Key from Nodesource 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 -
3.- Manually run sudo apt-get update
.
This refreshes the data from the nodesource repo so apt knows a newer version exists.
If you get a NO_PUBKEY GPG error, then go back to Step 2
4.- Check apt-cache policy nodejs
output.
This is not done by the script, but you want to make sure you see an entry that says something like this in the output:
Version table:
*** 9.2.0-1nodesource1 0
500 https://deb.nodesource.com/node_9.x/ jessie/main amd64 Packages
100 /var/lib/dpkg/status
0.10.29~dfsg-2 0
500 http://ftp.debian.org/debian/ jessie/main amd64 Packages
If you do not see entries like this, and only see 0.10.29, start over. Otherwise, proceed.
5.- Install the nodejs binary. Now that you have confirmed 9.x is available on your system, you can install it: sudo apt-get install nodejs
nodejs -v
should now show v9.2 or similar on output (as long as it starts with v9. you're on version 9 then).