Node Red 3 in Beaglebone Black


Many people asked how to update Node Red in Beaglebone. Current version is 3.0 and Beaglebone ships version 1.0…

Preparation

Remove obsolete NodeRed installation so it won’t make troubles.

sudo apt remove bb-node-red-installer nodejs c9-core-installer

Update NodeJS

Now download current LTS NodeJS

cd /tmp
wget https://nodejs.org/dist/v18.16.0/node-v18.16.0-linux-armv7l.tar.xz
tar -xf node-v18.16.0-linux-armv7l.tar.xz
rm node-v18.16.0-linux-armv7l.tar.xz node-v18.16.0-linux-armv7l/README.md node-v18.16.0-linux-armv7l/LICENSE node-v18.16.0-linux-armv7l/CHANGELOG.md
cd node-v18.16.0-linux-armv7l
sudo cp -R * /usr/local/

Now run

node --version

And make sure that you have NodeJS which you installed.

Install Node Red

Be logged in as Debian user! To install Node Red simply run:

npm install node-red

Now create 2 files:

/lib/systemd/system/nodered.service
/lib/systemd/system/nodered.socket

First file content (use eg sudo nano /lib/systemd/system/nodered.service )

[Unit]
Description=Node-RED graphical event wiring tool
Wants=network.target
Documentation=https://nodered.org/docs/
After=multi-user.target

[Service]
Type=simple
User=debian
Group=debian
RestartSec=250
Environment="NODE_PATH=/home/debian/node_modules"
Environment="NODE_OPTIONS=--max_old_space_size=256"
Environment="HOME=/home/debian/.node-red"
ExecStart=/usr/bin/env /usr/local/bin/node $NODE_OPTIONS /home/debian/node_modules/node-red/red.js $NODE_RED_OPTIONS
KillSignal=SIGINT
Restart=on-failure
SyslogIdentifier=Node-RED

[Install]
WantedBy=multi-user.target

Socket file content

[Unit]
Description=Node-RED Socket
PartOf=nodered.service

[Socket]
ListenStream=1880

[Install]
WantedBy=sockets.target

If both files are present then run:

sudo systemctl daemon-reload
sudo systemctl enable --now nodered

It’s done!