node-RED won't start, Failed with result 'exit-code'

Hi,

I don't know if deploying a new flow is the cause but from then on node-RED won't start anymore but stays in a start-restart loop. I see an error in the log file but have no idea how to solve it from the command line.
All help is appreciated

Attached the boot log:

pi@Rpi4:~ $ node-red-start

Start Node-RED

Starting as a systemd service.
11 Jul 18:57:57 - [info]
Welcome to Node-RED
===================
11 Jul 18:57:57 - [info] Node-RED version: v2.2.0
11 Jul 18:57:57 - [info] Node.js  version: v12.22.11
11 Jul 18:57:57 - [info] Linux 5.10.103-v7l+ arm LE
11 Jul 18:57:58 - [info] Loading palette nodes
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named rpi_ws281x
nodered.service: Main process exited, code=exited, status=1/FAILURE
nodered.service: Failed with result 'exit-code'.
nodered.service: Service RestartSec=100ms expired, scheduling restart.
nodered.service: Scheduled restart job, restart counter is at 1.
Stopped Node-RED graphical event wiring tool.
Started Node-RED graphical event wiring tool.
11 Jul 18:58:11 - [info]
Welcome to Node-RED
===================
11 Jul 18:58:11 - [info] Node-RED version: v2.2.0
``` etc etc..

Try starting node red with the --safe flag:

node-red --safe - Starts node-red with no flows running.

It looks like

ImportError: No module named rpi_ws281x

is the problem. Are you using a Neopixel node?

Good evening @ghayne, thanks for reading.

Yes, I have a flow that handles a neopixel lamp (worked well before this issue) but as far as I remember it does'n use the module named rpi_ws_281x

The safe option gives the same error

pi@Rpi4:~/node_modules $ node-red --safe
11 Jul 19:22:31 - [info]

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

11 Jul 19:22:31 - [info] Node-RED version: v2.2.0
11 Jul 19:22:31 - [info] Node.js  version: v12.22.11
11 Jul 19:22:31 - [info] Linux 5.10.103-v7l+ arm LE
11 Jul 19:22:31 - [info] Loading palette nodes
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named rpi_ws281x

Which Neopixel node(s) are you using?
Or are you calling a Python script from node-red?

I control the neopixels via MQTT. The Neopixels are connected to a Wemos D1 and I think the rpi_ws281x message is from an old flow and should be removed .. just I don't know how.

I did a search rpi_ws281x in my flows_Rpi4.json file but there is no pi_ws281x entry in that file

UPDATE: (I should have had another cup of coffee)
I see you know what the flow is (flows_Rpi4.json) so just paste that to a reply.

Thank you zenofmud,

Here it is...contains a lot of flows :wink:

flows_Rpi4.json (628.6 KB)

Isn't the error occurring during loading the nodes rather than the flows?

@maru could you temporarily rename the flows file and restart node-red and see what the error is then?

Hi Colin,

I renamed the file and indeed the error remains:

pi@Rpi4:~/.node-red $ ls -al
total 3128
drwxr-xr-x    5 pi pi   4096 Jul 11 23:21 .
drwxr-xr-x   15 pi pi   4096 Jul 11 18:44 ..
-rw-r--r--    1 pi pi  57534 Jan 31 14:17 .config.json
-rw-r--r--    1 pi pi  57537 Jan 31 11:04 .config.json.backup
-rw-r--r--    1 pi pi      2 Jan 31 18:50 .config.modules.json
-rw-r--r--    1 pi pi 127340 Jul 11 18:34 .config.nodes.json
-rw-r--r--    1 pi pi  88121 Jul 11 18:34 .config.nodes.json.backup
-rw-r--r--    1 pi pi      2 Jan 31 18:50 .config.projects.json
-rw-r--r--    1 pi pi     95 Jan 31 18:50 .config.runtime.json
-rw-r--r--    1 pi pi    809 Jul  9 22:04 .config.users.json
-rw-r--r--    1 pi pi    810 Jul  9 22:04 .config.users.json.backup
-rwxr-xr-x    1 pi pi    492 May  6  2020 flows_raspberrypi_cred.json
-rwxr-xr-x    1 pi pi  22678 May  6  2020 flows_raspberrypi.json
-rw-r--r--    1 pi pi  26467 May  6  2020 flows_raspi4RP14_Backup.json
-rwxr-xr-x    1 pi pi    480 May  6  2020 flows_raspi4RP14_cred.json
-rwxr-xr-x    1 pi pi  26467 May  6  2020 flows_raspi4RP14.json
-rw-r--r--    1 pi pi 649034 Jul 11 19:43 flows_Rpi4_Backup.json
-rw-r--r--    1 pi pi   6412 Jul 10 00:26 flows_Rpi4_cred.json
-rw-r--r--    1 pi pi   6572 Jul 10 00:26 .flows_Rpi4_cred.json.backup
-rw-r--r--    1 pi pi 643650 Jul 11 14:27 flows_Rpi4.json
-rw-r--r--    1 pi pi 649034 Jul 11 14:27 flows_Rpi4_old.json
drwxr-xr-x    3 pi pi   4096 May  5  2020 lib
-rw-r--r--    1 pi pi      0 Jul 11 18:44 luftkvalitet.log
drwxr-xr-x 1416 pi pi  45056 Jul 11 17:23 node_modules
-rw-r--r--    1 pi pi  48725 Jul 11 18:44 openaq.log
-rw-r--r--    1 pi pi   4700 Jul 11 17:16 package.json
-rw-r--r--    1 pi pi 641220 Jul 11 17:16 package-lock.json
drwxr-xr-x    2 pi pi   4096 Jul 11 18:44 scratch
-rw-r--r--    1 pi pi  12514 Jul 11 18:33 settings.js
pi@Rpi4:~/.node-red $ mv flows_Rpi4.json flows_Rpi4.json_Backup
pi@Rpi4:~/.node-red $ node-red-start

Start Node-RED

Once Node-RED has started, point a browser at http://192.168.1.54:1880
On Pi Node-RED works better with the Firefox or Chrome browser

Use   node-red-stop                          to stop Node-RED
Use   node-red-start                         to start Node-RED again
Use   node-red-log                           to view the recent log output
Use   sudo systemctl enable nodered.service  to autostart Node-RED at every boot
Use   sudo systemctl disable nodered.service to disable autostart on boot

To find more nodes and example flows - go to http://flows.nodered.org

Starting as a systemd service.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named rpi_ws281x
nodered.service: Main process exited, code=exited, status=1/FAILURE
nodered.service: Failed with result 'exit-code'.
nodered.service: Service RestartSec=100ms expired, scheduling restart.
nodered.service: Scheduled restart job, restart counter is at 116.
Stopped Node-RED graphical event wiring tool.
Started Node-RED graphical event wiring tool.
11 Jul 23:23:21 - [info]
Welcome to Node-RED
===================
11 Jul 23:23:21 - [info] Node-RED version: v2.2.0
11 Jul 23:23:21 - [info] Node.js  version: v12.22.11
11 Jul 23:23:21 - [info] Linux 5.10.103-v7l+ arm LE
11 Jul 23:23:22 - [info] Loading palette nodes
^Z

Have you made any changes to your settings.js file?

What happens if you stopNR and then start it with
node-red test.flow

a google search of rpi_ws281x shows it to be a

rpi_ws281x

Userspace Raspberry Pi library for controlling WS281X LEDs. This includes WS2812 and SK6812RGB RGB LEDs Preliminary support is now included for SK6812RGBW LEDs (yes, RGB + W) The LEDs can be controlled by either the PWM (2 independent channels) or PCM controller (1 channel) or the SPI interface (1 channel).

I found an neopixel entry in .config.nodes.json

    "node-red-node-pi-neopixel": {
        "name": "node-red-node-pi-neopixel",
        "version": "0.1.1",
        "local": true,
        "user": true,
        "nodes": {
            "rpi-neopixels": {
                "name": "rpi-neopixels",
                "types": [
                    "rpi-neopixels"
                ],
                "enabled": true,
                "local": true,
                "user": false,
                "module": "node-red-node-pi-neopixel",
                "file": "/home/pi/.node-red/node_modules/node-red-node-pi-neopixel/neopixel.js"

I made a backup, deleted that entry but still the same error and node-RED wo'nt start

pi@Rpi4:~/.node-red $ node-red test.flow
11 Jul 23:55:08 - [info]

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

11 Jul 23:55:08 - [info] Node-RED version: v2.2.0
11 Jul 23:55:08 - [info] Node.js  version: v12.22.11
11 Jul 23:55:08 - [info] Linux 5.10.103-v7l+ arm LE
11 Jul 23:55:09 - [info] Loading palette nodes
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named rpi_ws281x
pi@Rpi4:~/.node-red $

Is node-red-node-pi-neopixel something you installed recently?

No, maybe a long time ago, can't remember.

Thank you all, time to g to bed for me :wink:

Well I have partly reproduced the error. After installing node-red-node-pi-neopixel and stop/starting NR I get:

pi@testpi:~ $ node-red
11 Jul 18:01:23 - [info] 

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

11 Jul 18:01:23 - [info] Node-RED version: v2.2.2
11 Jul 18:01:23 - [info] Node.js  version: v14.20.0
11 Jul 18:01:23 - [info] Linux 5.10.63-v7+ arm LE
11 Jul 18:01:24 - [info] Loading palette nodes
11 Jul 18:01:33 - [info] Worldmap version 2.26.1
11 Jul 18:01:33 - [info] Dashboard version 3.1.6 started at /ui
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'rpi_ws281x'
11 Jul 18:01:34 - [warn] rpi-neopixels : rpi-gpio.errors.ignorenode
11 Jul 18:01:34 - [info] Settings file  : /home/pi/.node-red/settings.js
11 Jul 18:01:34 - [info] Context store  : 'default' [module=memory]
11 Jul 18:01:34 - [info] User directory : /home/pi/.node-red
11 Jul 18:01:34 - [info] Projects directory: /home/pi/.node-red/projects
11 Jul 18:01:34 - [info] Server now running at http://127.0.0.1:1880/
11 Jul 18:01:34 - [info] Active project : 00-bret-sensehat
11 Jul 18:01:34 - [info] Flows file     : /home/pi/.node-red/projects/00-bret-sensehat/flow.json
11 Jul 18:01:34 - [info] Starting flows
about to spawn
spawn done
11 Jul 18:01:35 - [info] Started flows

so there seems to be something with that node.

Since it seems that you are not using it please remove it. stop NR and run:

cd $HOME/.node-red
npm uninstall node-red-node-pi-neopixel

Then restart Node-RED. You may see something like this in the log:

11 Jul 18:12:08 - [warn] Missing node modules:
11 Jul 18:12:08 - [warn]  - node-red-node-pi-neopixel (2.0.0): rpi-neopixels
11 Jul 18:12:08 - [info] Removing modules from config

but it will only show the first time.

Might I also suggest you update to NR v2.2.2 and seeing how you have so many tabs and they look like different tests, take a look at using the 'projects' feature where you can swap between different projects when you want to play with something.

Thank you for the test :+1:

Unfortunately I get the same error after uninstalling node-red-node-pi-neopixel. I then performed a node-red upgrade, but even then when I start node-red I get the same error again. Then I ran npm uninstall node-red-node-pi-neopixel again (so in v2.2.2) and now I get the following startup loop

Welcome to Node-RED
===================
12 Jul 11:04:09 - [info] Node-RED version: v2.2.2
12 Jul 11:04:09 - [info] Node.js  version: v12.22.12
12 Jul 11:04:09 - [info] Linux 5.10.103-v7l+ arm LE
12 Jul 11:04:09 - [info] Loading palette nodes
nodered.service: Main process exited, code=exited, status=1/FAILURE
nodered.service: Failed with result 'exit-code'.
nodered.service: Service RestartSec=100ms expired, scheduling restart.
nodered.service: Scheduled restart job, restart counter is at 37.
Stopped Node-RED graphical event wiring tool.
Started Node-RED graphical event wiring tool.
12 Jul 11:04:21 - [info]
Welcome to Node-RED
===================
12 Jul 11:04:21 - [info] Node-RED version: v2.2.2
12 Jul 11:04:21 - [info] Node.js  version: v12.22.12
12 Jul 11:04:21 - [info] Linux 5.10.103-v7l+ arm LE
12 Jul 11:04:22 - [info] Loading palette nodes
nodered.service: Main process exited, code=exited, status=1/FAILURE
nodered.service: Failed with result 'exit-code'.
nodered.service: Service RestartSec=100ms expired, scheduling restart.
nodered.service: Scheduled restart job, restart counter is at 38.
Stopped Node-RED graphical event wiring tool.
Started Node-RED graphical event wiring tool.
12 Jul 11:04:34 - [info]
Welcome to Node-RED

Attached the npm uninstall node-red-node-pi-neopixel logfile with many errors
2022-07-12T08_26_19_191Z-debug.log (682.9 KB)

Can you check to see if it was removed;

cd $HOME/.node-red/node_modules
ls node-red-node-pi-neopixel

If the folder is there, remove it
rm node-red-node-pi-neopixel

Then run

node-red-stop
node-red test.flow —safe

And copy/paste the start up log

I think that should be
node-red-stop
node-red test.flow —safe

oh fudge, I only used one back tic instead of three so it put it all on one line. Thanks @Colin for spotting that (I've fixed it)

Hi Paul,

There was a directory and I removed it. The error message is gone but nothing happens (it hangs). Looks like it can not load the nodes. .

pi@Rpi4:~/.node-red/node_modules $ ls node-red-node-pi-neopixel
colours.js  LICENSE  neopix  neopixel.html  neopixel.js  neopix.py  package.json  README.md  scripts
pi@Rpi4:~/.node-red/node_modules $ rm node-red-node-pi-neopixel
rm: cannot remove 'node-red-node-pi-neopixel': Is a directory
pi@Rpi4:~/.node-red/node_modules $ rm -d -r node-red-node-pi-neopixel
pi@Rpi4:~/.node-red/node_modules $ node-red-stop
Stop Node-RED

Use   node-red-start   to start Node-RED again

pi@Rpi4:~/.node-red/node_modules $ node-red test.flow -safe
12 Jul 22:25:24 - [info]

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

12 Jul 22:25:24 - [info] Node-RED version: v2.2.2
12 Jul 22:25:24 - [info] Node.js  version: v12.22.12
12 Jul 22:25:24 - [info] Linux 5.10.103-v7l+ arm LE
12 Jul 22:25:25 - [info] Loading palette nodes