9

I used to install nodejs12 on Raspbian by simply adding the repo and using apt:

sudo su
curl -sL https://deb.nodesource.com/setup_12.x | bash -
apt install -y nodejs

But with a fresh install of Raspbian Buster I just got this message when adding the 12.x repos:

You appear to be running on ARMv6 hardware. Unfortunately this is not currently supported by the NodeSource Linux distributions. Please use the 'linux-armv6l' binary tarballs available directly from nodejs.org for Node.js 4 and later.

So I went over to the Nodejs Downloads page, and there I found that only ARMv7 and ARMv8 builds are available, where my Raspi zero is a ARMv6.

I can of course build from source, but if possible I want to avoid doing that. Does anybody know what the current way of installing Nodejs 12 on Raspbian is?

kramer65
  • 315
  • 1
  • 2
  • 9

3 Answers3

8

As of about April last year, it seems, NodeJS support for Armv6 moved to experimental see this thread for the RFC / discussion / reasoning etc. Armv6 is still supported and maintained on an experimental basis with all the caveats that word entails. The project is hosted at github and the binaries can be downloaded from here downloads. The site is a basic engineering site so at the time of writing hasn't got the refinement of the official NodeJS downloads page but the net effect is the same: you can download a tarball with the NodeJS binaries.

Hargrovm
  • 211
  • 1
  • 1
3

I've updated the "one line install" CLI scripts in the github.com/sdesalas/node-pi-zero repository.

These are now pointing to the binaries in the Unofficial Builds Project.

For example:

v12.21.0 (Experimental)

$ wget -O - https://raw.githubusercontent.com/sdesalas/node-pi-zero/master/install-node-v12.21.0.sh | bash

And remember, friends dont let friends pipe to sh.

1

Expanding on what @hargrovm said you can use this script to automate the download and extraction of the (unofficial) version you want:

export NODE_VER=14.15.1
if ! node --version | grep -q ${NODE_VER}; then
  (cat /proc/cpuinfo | grep -q "Pi Zero") && if [ ! -d node-v${NODE_VER}-linux-armv6l ]; then
    echo "Installing nodejs ${NODE_VER} for armv6 from unofficial builds..."
    curl -O https://unofficial-builds.nodejs.org/download/release/v${NODE_VER}/node-v${NODE_VER}-linux-armv6l.tar.xz
    tar -xf node-v${NODE_VER}-linux-armv6l.tar.xz
  fi
  echo "Adding node to the PATH"
  PATH=$(pwd)/node-v${NODE_VER}-linux-armv6l/bin:${PATH}
fi

For more information, I've written an in-depth blog post about this and why it happens: How to install the latest NodeJS on Raspberry PI 0 W?