How do you install newest version of node.js on Raspberry Pi?

rynop picture rynop · Mar 11, 2017 · Viewed 24k times · Source

I want to install the latest stable version of Node.js on Raspberry Pi 3. How do I do it in such a way that a) I'm always able to update to latest LTS version b) Can easily switch between versions

Answer

rynop picture rynop · Mar 11, 2017

The Node version manager works great, even for ARM based processors (like Raspberry Pi).

You need to remove the existing version of node installed on Raspbian however (if you are using this distro):

Remove old:

sudo -i
apt-get remove nodered -y
apt-get remove nodejs nodejs-legacy -y
exit

Install n (it will also install latest stable Node.js):

curl -L https://git.io/n-install | bash

Verify:

pi@raspberrypi:~ $ node --version
nv7.6.0
pi@raspberrypi:~ $ npm --version
4.1.2