How to Install Node-RED On Ubuntu
Update August 2022: Updated version links
How to Install Node-RED on Ubuntu
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.
This guide does not require you to upgrade your available packages.
Installing nvm
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.1/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
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 14.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, v14.21.1 is the latest of version 14 available as of now.
In my case, I'd run nvm install v14.21.1
Installing Node-RED
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).
Installing pm2 (Recommended)
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/v14.21.1/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.
That's it!
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.
No hay comentarios:
Publicar un comentario