Installing Node-RED on Raspberry Pi or Linux





To install Node-RED on Raspberry Pi or Linux, follow this guide from Node-RED. Below is a summarized version:

Running Node-RED on Raspberry Pi/Linux

Prerequisites

Ensure you are using Raspberry Pi OS Bullseye, the currently supported version.

Installing and Upgrading Node-RED

We provide a script to install Node.js, npm, and Node-RED onto a Raspberry Pi. This script can also be used to upgrade an existing install when a new release is available.

Installation Steps

1. Download and Run the Installation Script:

Open a terminal on your Raspberry Pi and run the following command:

  • bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)

During the installation process, the installer will prompt you for some initial settings. If you make a mistake, you can customize the initial settings by running:

  • node-red admin init

One important option to select is:

  • Enable the Projects Feature: Select "Yes"

2. Script Actions:

  • Removes the existing version of Node-RED if present.

  • Ensures Node.js is at least v14. If less than v14, the script stops and prompts the user to decide whether to upgrade Node.js.

  • Installs Node.js 16 LTS release if no version is found.

  • Installs the latest version of Node-RED using npm.

  • Optionally installs a collection of useful Pi-specific nodes.

  • Sets up Node-RED to run as a service.

Running as a Service

The install script sets Node-RED to run as a service, which means it can run in the background and be enabled to automatically start on boot.

Service Commands:

Start Node-RED:

  • node-red-start

  • (Displays log output. Pressing Ctrl-C or closing the window does not stop the service; it keeps running in the background.)

Stop Node-RED:

  • node-red-stop

Restart Node-RED:

  • node-red-restart

View Node-RED Log:

  • node-red-log

Autostart on Boot

To enable Node-RED to run automatically when the Raspberry Pi is turned on or rebooted, use the following command:

  • sudo systemctl enable nodered.service

To disable the service, use:

  • sudo systemctl disable nodered.service

Opening the Editor

Once Node-RED is running, you can access the editor in a local browser.

  • On the Pi Desktop: Open this address: http://localhost:1880

  • From Another Machine: Use the hostname or IP address of the Pi: http://:1880. You can find the IP address by running:

    • hostname -I

Additional Information

An important file for Node-RED settings is settings.js. If you haven't changed the directory, it will be stored in /home/youruser/.node-red/settings.js.

Viewing Hidden Files

By default, the .node-red directory is hidden. To view it, right-click in the directory and select "Show Hidden."