Upgrading Nodejs on Raspberry Pi 2

I read about using the n helper for node to perform an upgrade, however this did not work for me.  Instead, I added another source and upgraded with apt-get.

If you see another way which consistently works, please let me know.  This worked for me, I had version 0.10 and this upgraded me to 0.12.

NOTE: I ran this as root, as sudo did not work.

You may want to perform an upgrade of packages before you do this.

sudo bash
 curl -sL https://deb.nodesource.com/setup_0.12 | bash -
 exit

The process should look something like this.

pi@central:~ $ sudo bash
root@central:/home/pi# curl -sL https://deb.nodesource.com/setup_0.12 | bash -

## Installing the NodeSource Node.js 0.12 repo...

## Populating apt-get cache...

+ apt-get update
 Hit http://archive.raspberrypi.org jessie InRelease
 Get:1 http://mirrordirector.raspbian.org jessie InRelease [15.0 kB]
 Hit https://deb.nodesource.com jessie InRelease
 Hit https://deb.nodesource.com jessie/main Sources
 Hit http://archive.raspberrypi.org jessie/main armhf Packages
 Hit https://deb.nodesource.com jessie/main armhf Packages
 Hit http://archive.raspberrypi.org jessie/ui armhf Packages
 Get:2 http://mirrordirector.raspbian.org jessie/main armhf Packages [8,963 kB]
 Get:3 https://deb.nodesource.com jessie/main Translation-en_AU [162 B]
 Hit http://archive.raspberrypi.org jessie/staging armhf Packages
 Get:4 https://deb.nodesource.com jessie/main Translation-en [162 B]
 Get:5 https://deb.nodesource.com jessie/main Translation-en_AU [162 B]
 Get:6 https://deb.nodesource.com jessie/main Translation-en [162 B]
 Get:7 https://deb.nodesource.com jessie/main Translation-en_AU [162 B]
 Get:8 https://deb.nodesource.com jessie/main Translation-en [162 B]
 Get:9 https://deb.nodesource.com jessie/main Translation-en_AU [162 B]
 Get:10 https://deb.nodesource.com jessie/main Translation-en [162 B]
 Get:11 https://deb.nodesource.com jessie/main Translation-en_AU [162 B]
 Ign https://deb.nodesource.com jessie/main Translation-en_AU
 Get:12 https://deb.nodesource.com jessie/main Translation-en [162 B]
 Ign https://deb.nodesource.com jessie/main Translation-en
 Ign http://archive.raspberrypi.org jessie/main Translation-en_AU
 Ign http://archive.raspberrypi.org jessie/main Translation-en
 Ign http://archive.raspberrypi.org jessie/staging Translation-en_AU
 Ign http://archive.raspberrypi.org jessie/staging Translation-en
 Ign http://archive.raspberrypi.org jessie/ui Translation-en_AU
 Get:13 http://mirrordirector.raspbian.org jessie/contrib armhf Packages [37.5 kB]
 Ign http://archive.raspberrypi.org jessie/ui Translation-en
 Get:14 http://mirrordirector.raspbian.org jessie/non-free armhf Packages [70.3 kB]
 Get:15 http://mirrordirector.raspbian.org jessie/rpi armhf Packages [1,356 B]
 Ign http://mirrordirector.raspbian.org jessie/contrib Translation-en_AU
 Ign http://mirrordirector.raspbian.org jessie/contrib Translation-en
 Ign http://mirrordirector.raspbian.org jessie/main Translation-en_AU
 Ign http://mirrordirector.raspbian.org jessie/main Translation-en
 Ign http://mirrordirector.raspbian.org jessie/non-free Translation-en_AU
 Ign http://mirrordirector.raspbian.org jessie/non-free Translation-en
 Ign http://mirrordirector.raspbian.org jessie/rpi Translation-en_AU
 Ign http://mirrordirector.raspbian.org jessie/rpi Translation-en
 Fetched 9,088 kB in 31s (285 kB/s)
 Reading package lists... Done

## Confirming "jessie" is supported...

+ curl -sLf -o /dev/null 'https://deb.nodesource.com/node_0.12/dists/jessie/Release'

## Adding the NodeSource signing key to your keyring...

+ curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
 OK

## Creating apt sources list file for the NodeSource Node.js 0.12 repo...

+ echo 'deb https://deb.nodesource.com/node_0.12 jessie main' > /etc/apt/sources.list.d/nodesource.list
 + echo 'deb-src https://deb.nodesource.com/node_0.12 jessie main' >> /etc/apt/sources.list.d/nodesource.list

## Running `apt-get update` for you...

+ apt-get update
 Hit http://mirrordirector.raspbian.org jessie InRelease
 Hit http://archive.raspberrypi.org jessie InRelease
 Get:1 https://deb.nodesource.com jessie InRelease [3,913 B]
 Hit http://mirrordirector.raspbian.org jessie/main armhf Packages
 Get:2 https://deb.nodesource.com jessie/main Sources [777 B]
 Hit http://archive.raspberrypi.org jessie/main armhf Packages
 Get:3 https://deb.nodesource.com jessie/main armhf Packages [976 B]
 Hit http://mirrordirector.raspbian.org jessie/contrib armhf Packages
 Hit http://archive.raspberrypi.org jessie/ui armhf Packages
 Get:4 https://deb.nodesource.com jessie/main Translation-en_AU [162 B]
 Hit http://mirrordirector.raspbian.org jessie/non-free armhf Packages
 Get:5 https://deb.nodesource.com jessie/main Translation-en [162 B]
 Hit http://archive.raspberrypi.org jessie/staging armhf Packages
 Get:6 https://deb.nodesource.com jessie/main Translation-en_AU [162 B]
 Hit http://mirrordirector.raspbian.org jessie/rpi armhf Packages
 Get:7 https://deb.nodesource.com jessie/main Translation-en [162 B]
 Get:8 https://deb.nodesource.com jessie/main Translation-en_AU [162 B]
 Get:9 https://deb.nodesource.com jessie/main Translation-en [162 B]
 Get:10 https://deb.nodesource.com jessie/main Translation-en_AU [162 B]
 Get:11 https://deb.nodesource.com jessie/main Translation-en [162 B]
 Get:12 https://deb.nodesource.com jessie/main Translation-en_AU [162 B]
 Ign https://deb.nodesource.com jessie/main Translation-en_AU
 Get:13 https://deb.nodesource.com jessie/main Translation-en [162 B]
 Ign https://deb.nodesource.com jessie/main Translation-en
 Ign http://archive.raspberrypi.org jessie/main Translation-en_AU
 Ign http://archive.raspberrypi.org jessie/main Translation-en
 Ign http://archive.raspberrypi.org jessie/staging Translation-en_AU
 Ign http://archive.raspberrypi.org jessie/staging Translation-en
 Ign http://archive.raspberrypi.org jessie/ui Translation-en_AU
 Ign http://archive.raspberrypi.org jessie/ui Translation-en
 Ign http://mirrordirector.raspbian.org jessie/contrib Translation-en_AU
 Ign http://mirrordirector.raspbian.org jessie/contrib Translation-en
 Ign http://mirrordirector.raspbian.org jessie/main Translation-en_AU
 Ign http://mirrordirector.raspbian.org jessie/main Translation-en
 Ign http://mirrordirector.raspbian.org jessie/non-free Translation-en_AU
 Ign http://mirrordirector.raspbian.org jessie/non-free Translation-en
 Ign http://mirrordirector.raspbian.org jessie/rpi Translation-en_AU
 Ign http://mirrordirector.raspbian.org jessie/rpi Translation-en
 Fetched 5,666 B in 17s (319 B/s)
 Reading package lists... Done

## Run `apt-get install nodejs` (as root) to install Node.js 0.12 and npm

Then use apt-get to perform the upgrade.

sudo apt-get upgrade

The upgrade should look similar to this.

pi@central:/home/pi# sudo apt-get upgrade
 Reading package lists... Done
 Building dependency tree
 Reading state information... Done
 Calculating upgrade... The following packages were automatically installed and are no longer required:
 libasn1-8-heimdal libc-ares2 libgssapi3-heimdal libhcrypto4-heimdal libheimbase1-heimdal libheimntlm0-heimdal libhx509-5-heimdal libkrb5-26-heimdal libroken18-heimdal libwind0-heimdal
 Use 'apt-get autoremove' to remove them.
 Done
 The following packages have been kept back:
 pypy-upstream raspberrypi-ui-mods
 The following packages will be upgraded:
 libimlib2 nodejs
 2 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
 Need to get 6,757 kB of archives.
 After this operation, 7,867 kB of additional disk space will be used.
 Do you want to continue? [Y/n] y
 Get:1 http://mirrordirector.raspbian.org/raspbian/ jessie/main libimlib2 armhf 1.4.6-2+deb8u2 [150 kB]
 Get:2 https://deb.nodesource.com/node_0.12/ jessie/main nodejs armhf 0.12.13-1nodesource1~jessie1 [6,608 kB]
 Fetched 6,757 kB in 9s (677 kB/s)
 (Reading database ... 135296 files and directories currently installed.)
 Preparing to unpack .../libimlib2_1.4.6-2+deb8u2_armhf.deb ...
 Unpacking libimlib2 (1.4.6-2+deb8u2) over (1.4.6-2+deb8u1) ...
 Preparing to unpack .../nodejs_0.12.13-1nodesource1~jessie1_armhf.deb ...
 Detected old npm client, removing...
 Unpacking nodejs (0.12.13-1nodesource1~jessie1) over (0.10.44-1nodesource1~jessie1) ...
 Processing triggers for man-db (2.7.0.2-5) ...
 Setting up libimlib2 (1.4.6-2+deb8u2) ...
 Setting up nodejs (0.12.13-1nodesource1~jessie1) ...
 Processing triggers for libc-bin (2.19-18+deb8u4) ...

 

As I use node for node_red, I restarted node_red after the upgrade.  I experienced no issues with node_red after the upgrade to 0.12.

 

UPDATE 29 April 2016: Upgrading to other newer versions of node.js works this way too.  I recently just upgraded to v6 this same way, just use a different url.  You can find the urls for different versions here.  Although make sure that you check dependencies for other programs which depend on it, like node_red.

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s