Updating Node-RED, npm, and Node.js

Introduction

If you’re reading this, then there is a good chance you use Node-RED for creating dashboards for your internet of things (IoT) devices. Node-RED is a great solution for controlling various IoT devices as well as for displaying the current status of these devices. As an example, here is a screenshot of one of my Node-RED dashboards:

Node-RED Dashboard

Like any other software package that you make use of, new versions of Node-RED get released every so often with various bug fixes and feature improvements. This post will show how to update your Node-RED instance as well as npm and Node.js.

NOTE: These commands are specific to Node-RED running on a Linux-based systems (e.g., Raspberry Pi). Commands for Windows will vary slightly.

What Versions Do I Have Installed?

Before you update Node-RED, npm, or Node.js, you might want to see what versions are installed. This is pretty easy to accomplish from the command line.

To see what version of npm is installed, run:

npm -v

To see what version of Node.js is installed, run:

node -v

Finally, to see what version of Node-RED is installed, run:

node-red --h

The results of these commands will looks something list this:

Version Commands

You can check the website for each package to see what the latest version is to determine if you need to update, or you can simply run the update commands (below) to determine if anything needs updated.

Let’s Update!

First, we’ll update npm by running:

sudo npm update -g

Next, we’ll update Node.js by running:

npm cache clean -f
sudo npm install --g npm

Finally, let’s update Node-RED by running:

sudo npm install -g -unsafe-perm node-red
node-red-restart

Let’s Verify!

You can re-run the version commands listed above to check which versions were installed during the updates. For Node-RED, you can also check on the Admin page by clicking on the “hamburger” menu icon and viewing the version number on the bottom of the menu.

Node-RED Version Number

Clicking on the version number in the menu will display additional information about the latest version and offer to provide you a tour. You can also read about previous updates.

Node-RED Version Information

Summary

As it turns out, updating Node-RED (and dependencies such as npm and Node.js) is pretty straightforward. You can simplify the process a bit, if you like, by combining the above commands into a single update script. Taking it a step further, you could setup a cron job to run the updates every so often to ensure you’re on the latest version. However, I generally don’t recommend this approach for systems that you heavily rely on since you could inadvertently introduce issues with a bad update.

If you have a favorite approach for keeping Node-RED up to date, please let us know in the comments below.

Thanks!

Related Articles

You might find these Node-RED articles interesting:

Related Posts