Can't run node-red

this is the node-red.service I created and it's not working as well :

[Unit]
Description=Node-RED
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/bin/node-red

[Install]
WantedBy=multi-user.target

how does it compare to the one we install for you using the Pi install script ?
which is the one here

change the file to ans still not working :

[Unit]
Description=Node-RED
After=network.target

[Service]
Type=simple
User=root
Group=root
WorkingDirectory=/home/root
Nice=5
Environment="NODE_OPTIONS=--max_old_space_size=256"

ExecStart=/usr/bin/env node-red
KillSignal=SIGINT
Restart=on-failure
SyslogIdentifier=Node-RED

[Install]
WantedBy=multi-user.target

i believe it happens after i run the " Auto start capability using SystemD" script from here :

https://nodered.org/docs/hardware/raspberrypi.html

so as user root - what happens if you just start node-red normally - ie. node-red ?

In case you want to start again, the install/upgrade script designed for the Pi works well with Debian and Debian derivatives such as Ubuntu.
https://nodered.org/docs/hardware/raspberrypi
[Edit] and that includes installing the systemd script to run node-red on startup.

I just had something odd happen, I created a working installation of node-red based on Raspbian 10, lite image on a Pi4. All good. I cloned the image, and the clone worked just fine on a different Pi4. I then cloned the original image again, and booted it on a PiZero.

But node-red failed to start. I got the started to many times error from systemctl start nodered. Also node-red-start failed. Got the "Failed to start Node-RED graphical event wiring tool." error repeated several times.

I then reran the installation script via:

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

And it failed on the install of Node.js. The log file (/var/log/nodered-install.log) was not that informative.

$ cat /var/log/nodered-install.log

***************************************

Started : Fri 26 Jun 2020 12:47:40 AM UTC
Running for user pi at /home/pi
Found global nodes:   :

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

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.
Already have nodejs
Now install nodejs
Versions: node: npm:

Checking sources.list and sources.list.d...

 $ cat sources.list
deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi

# cat nodesource.list
deb https://deb.nodesource.com/node_12.x buster main
deb-src https://deb.nodesource.com/node_12.x buster main

I deleted the nodesource.list file. Tried the node-red install as above, it failed again installing node.js.

Here is the kicker, my script run is trying to remove node.js. So I am not getting the same failure point as the top of this thread outlines.

Running Node-RED install for user pi at /home/pi on raspbian


This can take 20-30 minutes on the slower Pi versions - please wait.

  Stop Node-RED                       ✔
  Remove old version of Node-RED      ✔
  Remove old version of Node.js       -
  Leave existing Node.js              ✘   Failed to install Node.js - Exit
  Clean npm cache
  Install Node-RED core
  Move global nodes to local
  Install extra Pi nodes
  Npm rebuild existing nodes
  Add shortcut commands
  Update systemd script

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

Trying again...

# apt install build-essential git`
# bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)

Still failing at the same point, try to remove old version of node.js, trying to install node.js steps of the script.

# sudo apt update
# sudo apt upgrade

But all packages are update.

# sudo apt install nodejs
Reading package lists... Done
Building dependency tree
Reading state information... Done
nodejs is already the newest version (12.18.1-1nodesource1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Suspect newer version?

curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -

## Installing the NodeSource Node.js 14.x repo...


## You appear to be running on ARMv6 hardware. Unfortunately this is not currently supported by the NodeSource Linux distributions. Please use the 'linux-armv6l                                       ' binary tarballs available directly from nodejs.org for Node.js 4 and later.

So I explicitly remove node.js...

# sudo apt remove nodejs
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
  nodejs
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 84.3 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 47120 files and directories currently installed.)
Removing nodejs (12.18.1-1nodesource1) ...
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/lib' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/docs' not empty so not removed
Processing triggers for man-db (2.8.5-2) ...

It appears that the node red script gets tripped up between ARM 7v and ARM 6v based raspberry pi devices, because nodejs remove/install gets tripped up by same.

Finally, ran the node-red install script again... This time with no nodejs installed as noted above... and it seemed to work this time.

Running Node-RED install for user pi at /home/pi on raspbian


This can take 20-30 minutes on the slower Pi versions - please wait.

  Stop Node-RED                       ✔
  Remove old version of Node-RED      ✔
  Remove old version of Node.js       ✔
  Install Node.js for Armv6           ✔   Node v12.16.2   Npm 6.14.5
  Clean npm cache                     ✔
  Install Node-RED core               ✔   1.0.6
  Move global nodes to local          -
  Install extra Pi nodes              ✔
  Npm rebuild existing nodes          -
  Add shortcut commands               ✔
  Update systemd 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  Fri 26 Jun 2020 01:22:39 AM UTC  -  Finished  Fri 26 Jun 2020 01:49:38 AM UTC

What is not good, IMHO, that include nodejs and node-red preinstalled, I will have to have one for ARM v7 and one for ARM v6 Pi devices. That is a real PITA, IMHO.

The node-red script at some point knows the ARM processor architecture is different, but appears that it can't handle going from ARM v7 to ARM v6, because of this nodejs issue with same?

Is it reasonable for the node-red install script to handle this? Doing an apparent down grade from ARM v7 to ARM v6 compatible nodejs? Or is the strictly a nodejs install/upgrade/reinstall issue?

One solution, might be, to only do the node-red install post image boot, after explicit nodejs removal, but that is not very elegant.

As the docs point out, you can move an arm6 install to arm7 but not the other way, so you can create a single image from the 0 if you like and use that.. BUT any day now the pi4 will also support 64bit, so that may change again.

So having the installation script handle the issue is not viable? If so, understood, not knowing how complex the installation script is, it may not be feasible..

Looks like, to really do deployment right, and avoid issues over time, using base image, and then Ansible or other solution similar to do installation after initial boot seems to be the best strategic solution then.

Really looking forward to when Pi devices support PXE boot or something similar consistently. Enterprise developments love PXE.

Well by default the script looks to see if you have node already installed and if it "looks ok" (ie responds to node -v with a suitable number) then the script leaves it alone to save time - and we don't want to force a new install on folk who may have a stable working version. It can't tell (afaik) that the sd card has just been plugged into a new box as it doesn't have any history.

Of course there may indeed be ways round these - but whether they are viable or not would need investigation for what is a rather small edge case. Especially when the actual issue is due to the underlying OS and node.js itself and not Node-RED per se.

The other thing to bear in mind (going forwards) is that Arm6 is getting less and less support - the only nodejs builds currently are unofficial ones - https://unofficial-builds.nodejs.org/ so while we do our best to make it look easy sometimes you'll have to work it out yourself.

If it's really a big problem then I'm sure we would be happy to accept a pull request if someone spares the time to investigate.

That is the question... Is it worth it. Even though I am a big fan of robust design, and my instinct is that this should be handled by the script, even though the script is not responsible for the issue, I think in this case, no.

When the opportunity appears, maybe just add a warning in the start of the script stating that preinstalled nodejs for ARM v7 fails on ARM v6. My thinking is since the script is used to upgrade as will as install node-red, a warning would be helpful. I only found the issue when trying to re-run the script on an existing image because the original error in this thread was encountered.

Although ARM v6 is fading it will be around for a long time... I have no plans to retire my older Pi devices to the rubbish heap any time soon.

Wow... the node-red installation directly on my PiZero is a LOT slower than my Pi4! What a difference. Even with PiZero using a wired connection.

1 Like

The difference in raw computing power is huge. I don't know whether having more memory makes much difference to node-red but if you are running other stuff such as a browser then it may do.
I recommend not using a GUI at all on a Zero (I don't know whether you are), use Raspbian lite.
In fact if you are running the browser on the Zero it is probably mostly the browser that is running slow, rather than node-red.

Nope the UI will not be used except during development. Running node-red on pizero just a few flows to capture sensor data, and some information for synchronizing some deployed scripts. Headless model for the most part. I will use ansible initially, since I already have it in place, to make sure I have the riight version of nodejs and node-red staged on initial boot. I want to keep one universal boot image... but have to avoid some of the ARM v6 vs v7 conflicts, like nodejs for example, as node-red is deployed..

I may have misunderstood when you said the installation was slower, I thought you were using 'installation' as a noun, but I now think you meant the installation process took a long time.
So yes, it does take a long time to install on a zero, sometimes you have to enter the sudo password again half way through, which can be confusing.

Does Dave know about this?

I doubt if there is much that can be done about it, if the gap between sudo commands exceeds the system defined timeout then it will ask again.

1 Like

Right, the entire installation process was quite long on a PiZero, but in my case I did not get the password reprompt.

Did you have to enter your password at all?
I have just realised possibly why I get it but others not necessarily. The default installation on a pi is, I believe, to allow the user pi to use sudo without entering a password. I always change the user name (not good security to keep the default name) and disable the nopasswd setting.

1 Like

Right, install under pi user... No password prompt on install of any Pi, be it Pi4 or PiZero so far.