How To Install and Run Node-RED on Debian 9|10|11|12

Posted February 19, 2024
How To Install and Run Node-RED on Debian 9|10|11|12

Do you want to install Node-Red on a Debian machine? This guide teaches all the steps you need to install and run Node-Red on Debian of any version, such as Debian 9, 10, 11, and 12.

Node-Red is built to work on major Linux distributions. These steps are not limited to Debian 11. They work on all major Debian variants and will be enough to get your Node-Red server installed and running. You will learn:

  • The Steps of Installing Node-RED on a Debian machine
  • How to use Debian and run Node-RED as a Service
  • How to change the Node-RED default port and access the Node-RED server.

Related:

Ready? Dive and learn to Install and Run Node RED on Debian.

Step 1: What you need to Install Node-RED on Debian

Before running Node-Red on Debian, you need to ensure:

  • This guide assumes you have Debian already installed and configured.
  • Node-RED uses Node.js and NPM. Ensure Debian has a Node.js runtime ready, it must be >=14.16'. If Not, check the next step.

Step 2: Update Debian Update Package List

Before installing Node.js and Node-Red, ensure your Debian package list repository is to the most recent versions. Use the following commands:

Check the packages that can be updated:

sudo apt update

Use the upgrade command to update them:

sudo apt upgrade -y

Step 3: Installing Node.js on Debian for Node-Red

Debian will require you to use Node.js before Node-RED. However, you must use Node.js version >=14.16'. Use the following command to get a Node repository based on the version you want to use. I will use 18 as follows:

curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash -

Installing Node.js on Debian for Node-Red

Now, use apt-get to install Node.js and get it ready on Debian to use Node-Red:

sudo apt-get install nodejs -y

Installing Node.js on Debian for Node-Red

To confirm Node.js is ready, use node -v for checking Node.js and npm -v to check NPM. You should get the installed versions as follows:

node -v
npm -v

How To Install and Run Node RED on Debian 9|10|11|12

This confirms Debian is now ready to run a Node-Red server.

Step 4: Installing Node-RED on Debian

To allow Debian to have access to Node-RED, you need to make sure Npm INSTALL THE node-red packages globally on your machine. Use the following command:

sudo npm install -g node-red

Installing Node-RED on Debian

At the same time, you may add a --unsafe-perm flag. It overrides permissions-related issues that might occur during Node-Red Debian installation.

sudo npm install -g --unsafe-perm node-red
  • The -g/--global tells npm to install the Node-RED globally.
  • node-red is the package you need to install based on the NPM registry.

Step 5: Running and Accessing Node-RED on Debian

You only need a single command to make Debian ready to serve you with Node-RED. In your terminal, use the following command to run Node-RED:

node-red

Running node-red should start the Node-RED server as follows:

Running and Accessing Node-RED on Debian

In this case, Node-RED initializes and starts the server, and you can use Debian to listen for incoming Node-RED connections.

Step 6: Accessing Node-RED on Debian

To be sure Node-RED is working within your Debian machine, access the Node-RED editor. Navigate to the http://localhost:1880 address on your web browser.

Here is your first visual of a Node-Red server:

Accessing Node-RED on Debian

Step 7: Running Node-Red as a Service

You have to use node-red every time you want Debian to run Node-RED. However, if you run Node-RED as a service, Debian starts Node-Red automatically every time the system boots up.

To make this work, you need to use PM2 as a process manager for Node.js as follows:

  • Install PM2 globally using NPM:
sudo npm install -g pm2

Running Node-Red as a Service

  • Start Node-RED using PM2:
pm2 start `which node-red` -- -v

Running Node-Red as a Service

  • Save the current PM2 process list to ensure that Node-RED starts automatically on Debian system boot:

Running Node-Red as a Service

  • PM2 provides a startup script to manage processes on system boot. Ensure it is installed:

Running Node-Red as a Service

Copy the Start up script and run it. (Check the above image To set up the startup script. copy/paste the following command)

  • Now use the following command to monitor the Node-RED process using PM2 :
pm2 monit

This command opens a monitoring interface. Check the running Node-RED process:

Running Node-Red as a Service

Conclusion

You now have a Node-RED server installed and ruing you your Debian 9|10|11|12 machine. I hope you found this guide helpful.

How To Install and Run Node-RED on Debian 9|10|11|12

Written By:

Joseph Chege