yatil.net
EN raspberry pi

Updating Node.js on a Raspberry Pi Zero

As the Raspberry Pi Zero is based on an older processor technology, the Node.js core team does not provide compiled binaries of newer versions. Here’s a quick guide on how to update anyway.

I use my Raspberry Pi Zero mainly for Homebridge, a way to use non-Homekit devices from my iPhone, iPad and Mac. Homebridge is based on Node.js but as the Pi is based on ARMv6, there is no official version of Node since version 10.x. Newer plugins demand later versions of Node, so I had to find a way to install it.

Fortunately it is pretty straight forward to install it from an unofficial repository. I followed the instructions on this web page, but I replaced the source of the compiled build.

  1. Connect to your Raspberry Pi using SSH.

  2. Find the latest build you want to install at unofficial-builds.nodejs.org/download/release/

    When I tried it, the current version was v15.1.0. In the current directory find the version for ARMv6, which is the file that ends with -armv6l.tar.gz.

    Make sure to use the correct version number in the commands below.

  3. On the command line on the Raspberry Pi download that file using the following command:

    curl -o node-v15.1.0-linux-armv6l.tar.gz https://nodejs.org/dist/v15.1.0/node-v15.1.0-linux-armv6.tar.gz
  4. Extract the files by using the tar command:

    tar -xzf node-v15.1.0-linux-armv6l.tar.gz
  5. Move the files over from the extracted directory:

    sudo cp -r node-v15.1.0-linux-armv6l/* /usr/local/
  6. In case you are greeted with the following error message:

    cp: cannot create regular file '/usr/local/bin/node': Text file bus

    You need to remove the node file first:

    sudo rm /usr/local/bin/node
  7. Restart the Pi or Homebridge to make the changes stick.

In the end, the whole process was not too bad and felt actually pretty straight forward once I found the unofficial builds.

They are unofficial and unsupported for a reason, so stuff might break in the future, but for now, everything looks good so far.

← Home