Corrupted node-red hangs immediately - added 'python' node seems to be to blame

I started a new flow to automate adding my solar panel data to a MariaDB.

I added three nodes to the palette

  1. crontab
  2. rsync
  3. python3

intention was to trigger rsync every day after sundown (around 23:00) to sync my inverter's USB storage, which collects each day's .csv file with a folder on my desktop, where I've collected all these files, since 2012. Previously, I've manually run LuckyBackup occasionally.

Half an hour later I was planning to run a python script on my desktop (via ssh) that parses the non-trivial .csv file(s) to insert the power & full timestamp to a desktop bases DB.

I hadn't decided whether I'd execute the python script directly on my desktop or run it on the Pi and just update the DB on my desktop. I installed a python3 node in the palette and dragged an instance into a flow, so I could take a look at its capability. Node-red stopped working and

root@DietPi:/# systemctl status node-red
â—Ź node-red.service - Node-RED (DietPi)
     Loaded: loaded (/etc/systemd/system/node-red.service; enabled; vendor preset: enabled)
    Drop-In: /etc/systemd/system/node-red.service.d
             └─dietpi-services_edit.conf
     Active: failed (Result: exit-code) since Sat 2025-10-18 15:22:29 BST; 7min ago
    Process: 31673 ExecStart=/mnt/dietpi_userdata/node-red/node_modules/.bin/node-red -u />
   Main PID: 31673 (code=exited, status=1/FAILURE)
        CPU: 7.017s

Oct 18 15:22:29 DietPi node-red[31673]: 18 Oct 15:22:29 - [error] [mqtt out:8e45101283d9fa>
Oct 18 15:22:29 DietPi node-red[31673]: 18 Oct 15:22:29 - [info] Started flows
Oct 18 15:22:29 DietPi node-red[31673]: [red] Uncaught Exception:
Oct 18 15:22:29 DietPi node-red[31673]: 18 Oct 15:22:29 - [error] Error: spawn python ENOE>
Oct 18 15:22:29 DietPi node-red[31673]:     at ChildProcess._handle.onexit (node:internal/>
Oct 18 15:22:29 DietPi node-red[31673]:     at onErrorNT (node:internal/child_process:484:>
Oct 18 15:22:29 DietPi node-red[31673]:     at process.processTicksAndRejections (node:int>
Oct 18 15:22:29 DietPi systemd[1]: node-red.service: Main process exited, code=exited, sta>
Oct 18 15:22:29 DietPi systemd[1]: node-red.service: Failed with result 'exit-code'.
Oct 18 15:22:29 DietPi systemd[1]: node-red.service: Consumed 7.017s CPU time.

Which contains Error: spawn python ENOE> which leads me to believe this node caused the problem.

I don't know where/how to expunge this node instance and palette entry via ssh (editor & dashboard don't work)

suggestions please?

As you can see, I run node-red on DietPi, as a service (systemctl start node-red)

I tried to work out how to set environment variables to start in 'safe mode' but description wasn't very good and I failed to do that

Also, please proved the exact/full names and a link to them in the library

Why cant you do this in Node-RED (without any need for python)? Tis quite simple to do!

You can start node-red in safe mode and use the palette manger to remove it

node-red --safe

or in a terminal, enter

cd path-to-node-red-user-dir-as-printed-in-start-of-log--usually.node-red
npm remove full-name-of-bad-node

If only I could start the editor to see the installed nodes (and their full names)? Alas, I can't and

root@DietPi:/# node-red-admin list
AggregateError

So, sorry not sure how?

Reason for python is that I already have a moderately complex python script that parses the file header to extract date and concatenate it with each line's time-stamp to create a full timestamp and has all the DB login working amongst other features, so I just wanted to not rewrite in another language, given that it just works.

I'll try that now

You can see the names of installed nodes in the package.json file in the node-red user directory (usually ~/.node-red)

As it's DietPi, it's installed from a constrained DietPi repo, as root user.

Any thoughts about which node-red folder I should be looking in?

root@DietPi:/# find / -name node-red -print
/root/node_modules/.bin/node-red
/root/node_modules/node-red
/root/node_modules/@node-red/editor-client/public/types/node-red
/mnt/dietpi_userdata/node-red
/mnt/dietpi_userdata/node-red/node_modules/.bin/node-red
/mnt/dietpi_userdata/node-red/node_modules/node-red
/mnt/dietpi_userdata/node-red/node_modules/@node-red/editor-client/public/types/node-red
/mnt/dietpi-backup/data/root/node_modules/.bin/node-red
/mnt/dietpi-backup/data/root/node_modules/node-red
/mnt/dietpi-backup/data/root/node_modules/@node-red/editor-client/public/types/node-red
/mnt/dietpi-backup/data/mnt/dietpi_userdata/node-red
/mnt/dietpi-backup/data/mnt/dietpi_userdata/node-red/node_modules/bcrypt/build-tmp-napi-v3/Release/.deps/mnt/dietpi_userdata/node-red
/mnt/dietpi-backup/data/mnt/dietpi_userdata/node-red/node_modules/.bin/node-red
/mnt/dietpi-backup/data/mnt/dietpi_userdata/node-red/node_modules/node-red
/mnt/dietpi-backup/data/mnt/dietpi_userdata/node-red/node_modules/@node-red/editor-client/public/types/node-red

I should have looked before asking you. Second entry seems to fit the bill

root@DietPi:~/node_modules/node-red# ll
total 124K
-rw-r--r--   1 root root  11K Feb 10  2024 LICENSE
drwxr-xr-x   2 root root 4.0K Feb 10  2024 bin
drwxr-xr-x   2 root root 4.0K Feb 10  2024 lib
-rwxr-xr-x   1 root root  21K Feb 10  2024 red.js
-rw-r--r--   1 root root 1.2K Feb 10  2024 package.json
-rw-r--r--   1 root root  32K Feb 10  2024 CHANGELOG.md
-rw-r--r--   1 root root 1.6K Feb 10  2024 README.md
drwxr-xr-x 259 root root  12K Feb 12  2024 ..
-rw-r--r--   1 root root  23K Jun 18 05:45 settings.js
drwxr-xr-x   4 root root 4.0K Jun 18 05:45 .

that is likely to be the node-red source.

what is in /mnt/dietpi_userdata/node-red?

PS, running as root is not a good idea and strongly discouraged!

How did you install node-red?
what do you see if you simply start node red from command line node-red?

The start up log of node-red reveals (definitively) where the user-dir is

e.g..

$ node-red

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

    18 Oct 14:11:22 - [info] Node-RED version: v4.1.1
    18 Oct 14:11:22 - [info] Node.js  version: v20.19.1
    18 Oct 14:11:22 - [info] Windows_NT 10.0.26100 x64 LE
    18 Oct 14:11:22 - [info] Loading palette nodes
    18 Oct 14:11:25 - [info] FlowFuse Light Theme Plugin loaded
    18 Oct 14:11:25 - [info] FlowFuse Dark Theme Plugin loaded
    18 Oct 14:11:31 - [info] Dashboard version 3.6.6 started at /ui
    18 Oct 14:11:31 - [info] FlowFuse AI Nodes: Using model cache directory: C:\Users\user1\repos\node-red\model_cache
    18 Oct 14:11:32 - [info] Settings file  : C:\Users\user1\.node-red\settings.js
    18 Oct 14:11:32 - [info] HTTP Static    : c:\temp > /
    18 Oct 14:11:32 - [info] Context store  : 'default' [module=memory]
    18 Oct 14:11:32 - [info] User directory : \Users\user1\.node-red  <<<<--------------- HERE
    18 Oct 14:11:32 - [warn] Projects disabled : editorTheme.projects.enabled=false
    18 Oct 14:11:32 - [info] Flows file     : \Users\user1\.node-red\blueprint-rag.json
    18 Oct 14:11:32 - [info] Server now running at http://127.0.0.1:1880/

I have to cd /root/node_modules/.bin/ and ./node-red --safe, which returns

(node:37945) [DEP0044] DeprecationWarning: The `util.isArray` API is deprecated. Please use `Array.isArray()` instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
/root/node_modules/node-red/red.js:500
        util.log('[red] Uncaught Exception:');
             ^

TypeError: util.log is not a function
    at process.<anonymous> (/root/node_modules/node-red/red.js:500:14)
    at process.emit (node:events:508:28)
    at process._fatalException (node:internal/process/execution:159:25)
    at throwUnhandledRejectionsMode (node:internal/process/promises:394:5)
    at processPromiseRejections (node:internal/process/promises:475:17)
    at process.processTicksAndRejections (node:internal/process/task_queues:106:32)

Node.js v24.8.0
root@DietPi:/mnt/dietpi_userdata/node-red# ll
total 708K
drwxrwxr-x  12 dietpi  dietpi  4.0K Sep 15 20:40 ..
-rw-r--r--   1 nodered nodered  26K Sep 15 20:41 settings.js
drwxr-xr-x   3 nodered nodered 4.0K Sep 15 20:41 lib
-rw-r--r--   1 nodered nodered  133 Sep 15 20:44 .config.runtime.json.backup
-rw-r--r--   1 nodered nodered  163 Sep 15 20:44 .config.runtime.json
drwxr-xr-x   4 nodered nodered 4.0K Sep 15 20:46 .npm
drwxr-xr-x   3 nodered nodered 4.0K Sep 15 20:47 .cache
-rw-r--r--   1 nodered nodered   51 Sep 15 20:48 flows_cred.json
drwxr-xr-x   2 nodered nodered 4.0K Sep 16 19:05 cronplusdata
-rw-r--r--   1 nodered nodered  748 Sep 18 17:35 .config.users.json.backup
-rw-r--r--   1 nodered nodered  747 Sep 18 17:35 .config.users.json
drwxr-xr-x 454 nodered nodered  20K Oct 18 10:06 node_modules
-rw-r--r--   1 nodered nodered  506 Oct 18 10:06 package.json
-rw-r--r--   1 nodered nodered 239K Oct 18 10:07 package-lock.json
-rw-r--r--   1 nodered nodered 130K Oct 18 10:16 .flows.json.backup
-rw-r--r--   1 nodered nodered 132K Oct 18 10:16 flows.json
-rw-r--r--   1 nodered nodered  51K Oct 18 11:00 .config.nodes.json.backup
-rw-r--r--   1 nodered nodered  51K Oct 18 11:00 .config.nodes.json
drwxr-xr-x   8 nodered nodered 4.0K Oct 18 15:20 .
drwxr-xr-x   2 nodered nodered 4.0K Oct 18 15:23 .node-red

looks like a hit?
I won't touch anything until I hear from you...

Yes.

Now you can list packages by cat package.json and see what dependencies are in there.

Once you get the full name of the python node, use npm remove xxxxx

root@DietPi:/mnt/dietpi_userdata/node-red# cat package.json
{
  "dependencies": {
    "@flowfuse/node-red-dashboard": "~1.29.0",
    "@mitch.capper/node-red-contrib-countdown-mc": "~2.0.1",
    "node-red": "^4.1.0",
    "node-red-contrib-cron-plus": "~2.2.4",
    "node-red-contrib-light": "~1.0.0",
    "node-red-contrib-python3-function": "~0.0.4",
    "node-red-contrib-rsync": "~1.1.1",
    "node-red-contrib-ui-iro-color-picker": "~0.1.6",
    "node-red-node-mysql": "~2.0.0",
    "node-red-node-ui-table": "~0.4.5",
    "node-red-node-watson": "~0.10.3"
  }
}

Thanks for your perserverance @Steve-Mcl . Got there in the end :innocent:

2 Likes

If you need to run a python script from node red I think the best way is to use an Exec node to run it. Make sure you specify the full path to the python interpreter and to the script file.