Introduction: Install Node RED on Your Raspberry Pi

Node-RED is a flow-based programming tool for wiring together hardware devices, APIs and online services in new and interesting ways.
It provides a browser-based editor that makes it easy to wire together flows using the wide range of nodes.

In this tutorial I will show you, how to install Node-RED on your Raspberry Pi.

Supplies

To install Node-RED, you need the following equipment:

Recommended:

Step 1: Setup

How to set up the Raspberry Pi?

If you download and install 'Raspbian Stretch with desktop and recommended software' on your Pi, Node-RED is already installed.

You can see how to start it at the end of the tutorial.

Step 2: Check for Updates

Type in this command to check for updates:

sudo apt-get update

Step 3: Download and Install NodeJS

First you have to find out which version of NodeJS you need. Type in this command to find out:
uname -m
If the response starts with armv6, then you will need the ARMv6 version. Otherwise, if it starts with armv7, you will need the ARMv7 version.
  1. Copy the link of the version you need from the NodeJS website
  2. Paste it after you type 'wget' in the console of your Pi
    wget [YOUR_NODEJS_DOWNLOAD_LINK]
    eg. wget https://nodejs.org/dist/v10.16.0/node-v10.16.0-linux-armv7l.tar.xz
  3. Press enter. NodeJS will now download
  4. After the download finished, extract the file
    tar xf [YOUR_DOWNLOADED_NODEJS_FILE]
    e.g. tar xf node-v10.16.0-linux-armv7l.tar.xz
  5. Navigate into the extracted directory
    cd [YOUR_EXTRACTED_DIRECTORY]
    e.g. cd node-v10.16.0-linux-armv7l
  6. Copy all files to '/usr/local/'
    sudo cp -R * /usr/local

Check if everything has installed successfully:

node -v
npm -v

Those commands should now return the version of node and npm. If they don't do that, you have probably downloaded the wrong NodeJS version.

Step 4: Install and Start Node-RED

Install Node-RED via the Node Package Manager:

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

After Node-RED has installed, you can start it with this command:

node-red

The response should be something like this:

Welcome to Node-RED
===================

25 Mar 22:51:09 - [info] Node-RED version: v0.20.5 25 Mar 22:51:09 - [info] Node.js version: v10.15.3 25 Mar 22:51:09 - [info] Loading palette nodes 25 Mar 22:51:10 - [warn] ------------------------------------------ 25 Mar 22:51:10 - [warn] [rpi-gpio] Info : Ignoring Raspberry Pi specific node 25 Mar 22:51:10 - [warn] ------------------------------------------ 25 Mar 22:51:10 - [info] Settings file : /home/nol/.node-red/settings.js 25 Mar 22:51:10 - [info] Context store : 'default' [module=localfilesystem] 25 Mar 22:51:10 - [info] User Directory : /home/nol/.node-red 25 Mar 22:51:10 - [warn] Projects disabled : set editorTheme.projects.enabled=true to enable 25 Mar 22:51:10 - [info] Server now running at http://127.0.0.1:1880/ 25 Mar 22:51:10 - [info] Creating new flows file : flows_noltop.json 25 Mar 22:51:10 - [info] Starting flows 25 Mar 22:51:10 - [info] Started flows

The address of the server will be displayed in the response. (it's bold in this sample response)

Node-RED is now available at: http://[IP_OF_YOUR_PI]:1880/

You have now successfully installed Node-RED on your Raspberry Pi!