Update January 2023: Updated version links
Update January 2024: Updated version links
I've found that installing Node-RED on Ubuntu can be an annoying task, but here's my combination of many guides to install Node-RED on Ubuntu 20.04 and newer.
You can sort of think of nvm as a package manger like apt, except that nvm only manages Node.js versions.
To install nvm, run this curl command to download it from their Github.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
Next, we'll run this following command to run the script you just downloaded from their Github.
source ~/.bashrc
That's it! Now you have nvm installed.
Installing Node.js (basically the back end of Node-RED) is super simple.
Now that we have nvm, you can just run
nvm install -version-
Before you do that, you'll want to find the latest Node.js version supported by Node-RED. You can see that here.
Node-RED typically just gives supported version ranges on their site, such as 20.x. However, you need to specify the version of Node.js you want. To find the available versions on nvm, run the command nvm ls-remote
You'll typically want the highest number in a release, for example, v20.11.0 is the latest of version 20 available as of now.
In my case, I'd run nvm install v20.11.0
Since we have Node.js installed, we can now use npm commands to install other packages. Now we are going to install Node-RED.
npm install -g --unsafe-perm node-red
This will tell npm to install node-red with the latest version to the directory of Node.js (that's the -g flag).
This part of the guide is not required, however it's super helpful to have Node-RED auto start on boot.
To install the utility to auto start Node-RED, run npm install -g pm2
Next, you'll want to tell pm2 to start Node-RED, BUT BEFORE YOU DO THAT, I've found that sometimes it doesn't work correctly. To fix this, start Node-RED manually. To start it manually, just run node-red
If this fails, you'll know where the problem is, but if it launches and it looks successful, cancel it by running CTRL+C
.
Now we can run the pm2 command to start Node-RED. pm2 start .nvm/versions/node/v20.11.0/bin/node-red -- -v
. You will want to replace the v14.18.3 with whatever version of Node.js eariler in this tutorial.
Then, once that succeeds, you'll want to run pm2 startup systemd
. It will output a command near the end that you'll want to copy and paste and run that to allow pm2 to start on boot. Finally, you'll run pm2 save
to save the configuration of the auto startup utility.
It's pretty simple to install Node-RED on Ubuntu if you know what commands to run. If you found this guide helpful, make sure to send it to others who may need help installing Node-RED.