Installing Node-RED on IGT-20 and IGT-21

Update 2020/5/8: Node.js 10 has been install successfully. And this article applies also to IGT-30D, IGT-31D, IGT-33V and IGT-34C.

Node-RED is a frequently used software package for IoT, Internet of Things, applications. Though the factory OS images of IGT-20 and IGT-21 don’t cover Node-RED by default, it’s easy to install Node-RED manually. Here’s a step-by-step instruction of installing Node-RED on IGT-20 or IGT-21. However, the default OS image allocates only around 800M while the default storage size is much larger. Do follow the step to expand the default partition, or otherwise, the disk will be full during the installation.

Expand Partition of IGT-20 and IGT-21

The original partition of IGT-20 / IGT-21 is only around 1GB, which is not enough for installing Node-RED. Please first follow the article to expand the partition.

There are three 3 stages to install Node-RED on IGT-20 and IGT-21. Firstly, there are some dependencies to be installed. Then Node.js is, of course, required. And finally, it’s Node-RED itself. The following command lines serve to complete the job.

Download Pre-requested Packages

apt-get install -y curl locales ntpdate avahi-utils python build-essential

Install Node.js

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y build-essential nodejs

or alternatively install Node.js LTS 8.x

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs

or alternatively install Node.js LTS 10.x (oh, my god. I’ve tried the 3rd version)

curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs

Install Node-RED

sudo npm i -g --unsafe-perm node-red

If everything goes smoothly, here Node-RED has been installed successfully. But making a configuration to have Node-RED running on boot-up is helpful.

Create Node-RED Service File

To make Node-RED to start after system boots up, the following command will create a node-red service fileĀ /lib/systemd/system/nodered.service

cat << EOF > /lib/systemd/system/nodered.service
# systemd service file to start Node-RED
[Unit]
Description=Node-RED graphical event wiring tool.
Wants=network.target
[Service]
Type=simple
# Run as root user in order to have access to gpio pins
User=root
Group=root
Nice=5
Environment="NODE_OPTIONS=--max-old-space-size=128"
#Environment="NODE_RED_OPTIONS=-v"
ExecStart=/usr/bin/env node-red-pi $NODE_OPTIONS $NODE_RED_OPTIONS
KillSignal=SIGINT
Restart=on-failure
SyslogIdentifier=Node-RED
[Install]
WantedBy=multi-user.target
EOF

Configure Node-RED Service to start up automatically

sudo systemctl daemon-reload
sudo systemctl enable nodered.service