Updating Raspberry Pi and Node.js to the latest version

Throughout this update you will need to use the terminal app in Raspberry Pi OS or remote SSH through Windows (see instructions at the end of this guide). *I really recommend the first option*.

Here’s a summary of the steps:

  1. Backup
  2. Raspberry Pi Package Updates
  3. Node.js Upgrade
  4. SSH using Windows 10 (remote terminal) (optional)

1- Backup! (Clone SD Card)

I really recommend creating a full backup of your install (setup) on another SD card by cloning it with the SD Card Copier application (already available in the Pi OS).

The SD Card Copier application, which can be found on the Accessories menu of the Raspberry Pi Desktop, will copy Raspberry Pi OS from one card to another. To use it, you will need a USB SD card writer.

To back up your existing Raspberry Pi OS installation, put a blank SD card in your USB card writer and plug it into your Pi, and then launch SD Card Copier. In the ‘Copy From Device’ box, select the internal SD Card. This could have a number of different names, and may have something like (/dev/mmcblk0) in its entry, but will usually be the first item in the list. Then select the USB card writer in the ‘Copy To Device’ box (where it will probably be the only device listed). Press ‘Start’. The copy, depending on the size of the SD card, can take ten or fifteen minutes, and when complete you should have a clone of your current installation on the new SD card.

You can test it by putting the newly-copied card into the Pi’s SD card slot and booting it; it should boot and look exactly the same as your original installation, with all your data and applications intact.

You can run directly from the backup, but if you want to recover your original card from your backup, simply reverse the process – boot your Pi from the backup card, put the card to which you want to restore into the SD card writer, and repeat the process above.

The program does not restrict you to only copying to a card the same size as the source; you can copy to a larger card if you are running out of space on your existing one, or even to a smaller card (as long as it has enough space to store all your files – the program will warn you if there isn’t enough space). It has been designed to work with Raspberry Pi OS and NOOBS images; it may work with other OSes or custom card formats, but this is not guaranteed.

The only restriction is that you cannot write to the internal SD card reader, as that would overwrite the OS you are actually running, which could break the installation completely.

Note, everything on the destination card will be overwritten, so ensure you do not have any critical data on it before starting the copy.

Source: https://www.raspberrypi.org/documentation/linux/filesystem/backup.md

2- Raspberry Pi Package Updates

Click the Pi button at the top left of the screen, then:
Preferences → Add/Remove Software → Options → Check for Updates → Install Updates (if required)

Once it’s done, click OK to close the add/remove software box. All packages on your Raspberry Pi are now up to date.

While it’s not required, I find it’s a good practice to reboot my Pi after updates (Raspberry Pi Button → Logout → Reboot).

3- Node.js Upgrade

Verify your Node.js version by typing the following in the terminal app

node -v

At this time (March 23rd 2022) the latest version should be 17.8.0, you can always check the latest version here: Previous Releases | Node.js (nodejs.org)

If you have the latest version, congrats, nothing to do! But if you don’t, you can upgrade by typing the following commands in the terminal app

curl -sL https://deb.nodesource.com/setup_17.x | sudo -E bash -
sudo apt install nodejs

That’s it! You should be upgraded to the latest version, verify by using the “node -v” command.

Again, I find it a good practice to reboot my Pi after significant updates, see step 3.

References on upgrade scripts:
Upgrading to more recent versions of Node.js on the Raspberry Pi | thisDaveJ

GitHub – nodesource/distributions: NodeSource Node.js Binary Distributions

4- SSH using Windows 10 (remote terminal)

In the Windows 10 taskbar searchfield (at the right of the Windows button) or in Windows Command prompt, type the following command (replace <IP> with the IP address of the Raspberry Pi) and press enter:

ssh pi@<IP>

Example: ssh pi@

You should be prompted for your password and then you’ll be on (remote) terminal mode.

Reference: https://www.raspberrypi.org/documentation/remote-access/ssh/windows10.md