Install Node-RED on Orange Pi running Armbian, auto start with PM2

Black Friday on Amazon right now! Black friday Banggood Gearbest Black Friday
Extra 10% off For XIAOMI SUPER HOME TECH GADGET Sale

Smart Home kits, security camera, robot vacuum cleaner, air purifier ... *Excluding products already on promotion

Reveal
35 days left

Node-RED is a development tool installed by default on the Raspbian distribution, the official Linux distribution of the Raspberry Pi. If you have decided to run your Orange Pi under Armbian, here’s how to install Node-RED. For this article, I installed Node-RED on Armbian and an Orange Pi Lite (Wi-Fi version).

Install Node-RED on Armbian

Installing Node-RED is now much easier with the installation script. Initially intended for the Raspbian distribution of the Raspberry Pi, it works perfectly on the Armbian distribution of Orange Pi. Log in SSH or open a Terminal and run the installation script by executing this command. The operation lasts about 15 minutes.

Start Node-RED on startup with PM2

There are several ways to start NR automatically on Mac (or Windows). Here I suggest you use PM2, a process manager for Node.js. The advantage is that this solution works on all platforms. Convenient, if you ever have the urge to develop on Raspberry Pi.

If you no longer know the Node-RED path, run this command

On macOS, it should be in /usr/local/bin/node-red .

To run NodeRED, run this command PM2

The configuration is saved and automatic start is activated

A short video to see how to do

Installing Node-RED on Armbian – Depreciated method

Do not use this method anymore. Use the detailed installation script previously.

The installation of Node-RED on Orange Pi (or Raspberry Pi) is different from other Linux distributions (how to install on Ubuntu 16.04 LTS) since it will have to install everything from the sources. Here’s how to do it step by step.

We start by doing some housekeeping in the package manager

Then we install Node-RED from the source code

Now the necessary dependencies: Node.js, Python, Build

Before going any further, we can check the installed versions

This complies with the Node-RED specifications (here).

Clean the npm cache and run the Node-RED installation. Attention, it is quite long, several minutes on an Orange Pi Lite because everything must be compiled for the ARM processor (Allwinner H3 @ 1,2GHz). I encountered a crash during this stage. I just restarted the command after reboot.

Finally we install the scripts that will start and stop Node-RED

All you have to do is activate the Node-RED service to enable it to start when Armbian starts.

It only remains to create the directory of operation of Node-RED.

You can add the node-red-admin module.

 

Here is a list of articles to go further with Node-RED

Source:

The installation procedure proposed in this tutorial is extracted from the installation script developed by Brian Weet https://gist.github.com/brianweet/a055f344f57cd485dc8b91cd18523002

Updates:

[06/28/2017] – installation using bash script

Subscribe to the weekly newsletter

No spam and no other use will be made of your email. You can unsubscribe anytime.

  • Asterion Daedalus

    Yeah, but no. Didn’t work for me.

    • Hello Asterion. Can you give us more information about your configuration and versions (armbian, nodejs…). Thank’s

      • Asterion Daedalus

        Armbian debian server from:
        https://dl.armbian.com/orangepizero/Debian_jessie_default.7z

        apt-get would fail when attempting to install nodejs so I used the binary install from:

        https://nodejs.org/dist/v6.11.0/node-v6.11.0-linux-armv7l.tar.xz

        Downloaded node-red then the usual way through npm.

        Runs fine from command line.

        So, I will have to look at the service scripts I assume? They might need tweaking.

        Error reported when using systemctrl start nodered.service is:
        ? nodered.service – Node-RED graphical event wiring tool.
        Loaded: loaded (/lib/systemd/system/nodered.service; disabled)
        Active: failed (Result: start-limit) since Wed 2017-06-14 09:34:56 CEST; 2s ago
        Docs: http://nodered.org/docs/hardware/raspberrypi.html
        Process: 1366 ExecStart=/usr/bin/env node-red-pi $NODE_OPTIONS $NODE_RED_OPTIONS (code=exited, status=217/USER)
        Main PID: 1366 (code=exited, status=217/USER)

        Jun 14 09:34:55 house systemd[1]: Unit nodered.service entered failed state.
        Jun 14 09:34:56 house systemd[1]: nodered.service holdoff time over, schedu…t.
        Jun 14 09:34:56 house systemd[1]: Stopping Node-RED graphical event wiring …..
        Jun 14 09:34:56 house systemd[1]: Starting Node-RED graphical event wiring …..
        Jun 14 09:34:56 house systemd[1]: nodered.service start request repeated to…t.
        Jun 14 09:34:56 house systemd[1]: Failed to start Node-RED graphical event …..
        Jun 14 09:34:56 house systemd[1]: Unit nodered.service entered failed state.

        • Ok. Can you give me the npm and node versions please. Did you try to follow the steps of the tutorial before? You must also install build-essential and python-dev

          • Asterion Daedalus

            npm -v
            3.10.10
            node -v
            6.11.0

          • Asterion Daedalus

            Nope, added build-essential an python-dev, reinstalled node-red. Still same problem. I also noted the step to create .node-red with mkdir is not necessary as it is created by the build. As for below, it looks like this post is out of date given the movement in npm and node versions.

          • Well, I have to re-install with the latest versions of npm and nodejs. On the other hand, everything works very well with the versions indicated in the article. I made several tutorials with this configuration. As soon as I have a little time, I update the article. If you find the solution before me, do not hesitate to contact me. Thank you very much.

          • Asterion Daedalus

            Cheers. I will keep at it.

          • Asterion Daedalus

            SOLVED. I just used PM2 as suggested from node-red site.

            What got me going was the following (from root):

            npm install -g pm2
            whereis node-red
            node-red: /usr/local/bin/node-red
            pm2 start /usr/local/bin/node-red –node-args=”–max-old-space-size=128″ — -v
            pm2 save
            pm2 startup
            export PM2_HOME=”/root/.pm2″ # because I installed in root otherwise PM2_HOME=”/root/{user}/.pm2″
            reboot #takes a while after rebooting but it should come up

          • Hi Asterion. I just updated the article. I used the new install script to install Node-RED. It works like a charm. He takes care of everything. Like you, I installed PM2 to automatically launch Node-RED at startup. It’s much simpler. Everything is done in 15 ‘on my Orange Pi Lite! See you soon i hope. Christophe

          • Asterion Daedalus

            Okay, I spotted one problem caused by the block copying of the service commands above, for the node-red-start script the wget finishes silently but was not copying the file to /usr/bin as it had random characters in URL and file name (substituting spaces). I tidied that up.

            However, error message is now:
            ? nodered.service – Node-RED graphical event wiring tool.
            Loaded: loaded (/lib/systemd/system/nodered.service; disabled)
            Active: failed (Result: start-limit) since Wed 2017-06-14 13:54:19 CEST; 5s ago
            Docs: http://nodered.org/docs/hardware/raspberrypi.html
            Process: 2737 ExecStart=/usr/bin/env node-red-pi $NODE_OPTIONS $NODE_RED_OPTIONS (code=exited, status=217/USER)
            Main PID: 2737 (code=exited, status=217/USER)

            Jun 14 13:54:18 house systemd[1]: Unit nodered.service entered failed state.
            Jun 14 13:54:19 house systemd[1]: nodered.service holdoff time over, scheduling restart.
            Jun 14 13:54:19 house systemd[1]: Stopping Node-RED graphical event wiring tool….
            Jun 14 13:54:19 house systemd[1]: Starting Node-RED graphical event wiring tool….
            Jun 14 13:54:19 house systemd[1]: nodered.service start request repeated too quickly, refusing to start.
            Jun 14 13:54:19 house systemd[1]: Failed to start Node-RED graphical event wiring tool..
            Jun 14 13:54:19 house systemd[1]: Unit nodered.service entered failed state.

DIY Projects