Install Node-RED on Raspbian Jessie Lite on a Raspberry Pi Zero W

The Lite version of Raspbian Jessie is very well suited to the limited resources of the Raspberry Pi Zero W. Node-RED is pre-installed on the version integrating the Pixel graphics desktop but this is not the case for the Lite version. Fortunately, there is an installation script now that takes care of everything!

Run the installation script

Everything is explained in detail here. Log in to SSH (read this article to learn how) to your Raspberry Pi Zero W and run this command

bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered)

This command launches the installation script that takes care of everything!

Running for user pi at /home/pi

This can take 20-30 minutes on a Pi 1 - please wait.

  Stop Node-RED                       ✔
  Remove old version of Node-RED      ✔
  Remove old version of node.js       ✔
  Install node.js for Armv6           ✔   Node v6.11.0   Npm 3.10.10
  Clean npm cache                     ✔
  Install Node-RED core               ✔   0.16.2 
  Install extra nodes                 ✔
  Install serialport node             ✔
  Npm rebuild existing nodes          ✔
  Add menu shortcut                   ✔
  Update systemd script               ✔
  Update update script                ✔

Any errors will be logged to   /var/log/nodered-install.log

All done.
  You can now start Node-RED with the command  node-red-start
  or using the icon under   Menu / Programming / Node-RED
  Then point your browser to localhost:1880 or http://{your_pi_ip-address}:1880

Started  Thu 22 Jun 14:42:28 UTC 2017  -  Finished  Thu 22 Jun 15:00:14 UTC 2017

The script performs the following operations

  • It stops and uninstalls the current version of Node-RED and Node.js. This step is not trivial if you have other projects based on Node.js
  • It then installs Node.js for OSC Arm V6
  • Installs Node-RED and systemd scripts that automatically run Node-RED at Raspbian startup

The installation script takes about 30 minutes on a Raspberry Pi Zero W. All the resources are compiled directly after the download. To follow the installation process, open a second SSH connection and execute the following command.

tail -f /var/log/nodered-install.log

Some useful commands

After the installation, it is necessary to manually activate the automatic start of Node-RED at the launch of Raspbian Jessie. To do this, execute the command

sudo systemctl enable nodered.service

On the contrary, to stop the service (you no longer need Node-RED and you wish to recover some resources), run the command

sudo systemctl disable nodered.service

To manually start Node-RED

node-red-start

Once launched, you can access Node-RED from any extension on the local network (including a tablet or smartphone).node-red start demarrage naviguateur

Start automatically with PM2

There is another option to start automatically. The PM2 Process Manager for Nodejs is recommended. PM2 provides other tools to more easily manage startup, shutdown, opening of the execution log, and so on. It’s much more flexible than using the Linux and systemd services. Begin by installing PM2 with this command:

sudo npm install -g pm2

If you do not know Node-RED path, run this command

which node-red

On Linux / Raspbian, it should be in /usr/bin/node-red .

To run NodeRED, run this command PM2

pm2 start /usr/bin/node-red -- -v

Finally, the configuration is saved and automatic start is activated. That’s all.

pm2 save
pm2 startup

 

To learn more about Node-RED, see the dedicated category.

Subscribe to the weekly newsletter

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

  • Joe Vogel

    Hi,

    I’m getting this error:

    Running for user pi at /home/pi
    Failed to stop nodered.service: Unit nodered.service not loaded.
    Found global nodes: :
    Reading package lists…
    Building dependency tree…
    Reading state information…
    Package ‘nodered’ is not installed, so not removed
    0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    cp: cannot stat ‘/usr/local/n/versions/node/8.11.2/lib’: No such file or directory
    cp: cannot stat ‘/usr/local/n/versions/node/8.11.2/include’: No such file or directory
    cp: cannot stat ‘/usr/local/n/versions/node/8.11.2/share’: No such file or directory

    I did a look om the specified folder and see this:

    pi@raspberrypi:/usr/local/n/versions/node/8.11.2 $ ls
    bin

    What I need to do in order to get these folders?

    Best Regards,
    Joe Vogel

DIY Projects