Node-red 18.0.0 won't start (SOLVED, see post 24)

Ok, found the “error” on myself. Calling the ID before everything was up and running. Now it looks better. Try 18.0 again

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

24 Jun 14:00:00 - [info] Node-RED version: v3.1.9
24 Jun 14:00:00 - [info] Node.js  version: v18.20.3
24 Jun 14:00:00 - [info] Linux 6.6.33-haos x64 LE
24 Jun 14:00:01 - [info] Loading palette nodes
24 Jun 14:00:02 - [info] Node-RED Contrib Theme Collection version: v3.1.11
24 Jun 14:00:07 - [info] Dashboard version 3.6.5 started at /endpoint/ui
24 Jun 14:00:09 - [info] Settings file  : /etc/node-red/config.js
24 Jun 14:00:09 - [info] Context store  : 'default' [module=localfilesystem]
24 Jun 14:00:09 - [info] Context store  : 'memoryOnly' [module=memory]
24 Jun 14:00:09 - [info] User directory : /config/
24 Jun 14:00:09 - [warn] Projects disabled : editorTheme.projects.enabled=false
24 Jun 14:00:09 - [info] Flows file     : /config/flows.json
24 Jun 14:00:09 - [info] Server now running at http://127.0.0.1:46836/
[14:00:09] INFO: Starting NGinx...
24 Jun 14:00:09 - [info] Starting flows
24 Jun 14:00:10 - [info] Started flows
24 Jun 14:00:14 - [info] [server:Home Assistant] Connecting to http://supervisor/core
24 Jun 14:00:14 - [info] [server:Home Assistant] Connected to http://supervisor/core

The error after upgrade to 18 is still the same. Need to make a rollback

[14:13:51] INFO: Starting Node-RED...

> start
> node $NODE_OPTIONS node_modules/node-red/red.js --settings /etc/node-red/config.js

/opt/node_modules/@node-red/util/lib/util.js:772
                })
                 ^

SyntaxError: Unexpected token ')'
    at internalCompileFunction (node:internal/vm:76:18)
    at wrapSafe (node:internal/modules/cjs/loader:1283:20)
    at Module._compile (node:internal/modules/cjs/loader:1328:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
    at Module.load (node:internal/modules/cjs/loader:1203:32)
    at Module._load (node:internal/modules/cjs/loader:1019:12)
    at Module.require (node:internal/modules/cjs/loader:1231:19)
    at require (node:internal/modules/helpers:177:18)
    at Object.<anonymous> (/opt/node_modules/@node-red/util/index.js:19:14)
    at Module._compile (node:internal/modules/cjs/loader:1364:14)

Node.js v18.20.3

oh, man. I am also one of the idiots not removing the “sed” command from the init_command in HA. Now everything is fine…

What init_command?

Home Assistant > Settings > Addons > Node-RED > Configuration > init_commands

These are commands run at initialization (hence init_commands) as Node-RED starts up.
If you still have the ‘patch’ from last year, then this command must be removed.

2 Likes

This won’t help anyone having issues right now but having been burned a few times on NR major releases I have found it to be best practice to wait until a x.0.1 release before attempting the upgrade. I am all about cutting edge adoption but NR is a pivotal part of my automation environment so I wait.

1 Like

.

.
.
.
.
doh(300)

2 Likes

This did the trick for me:
Removing “sed -i “772,775d” /opt/node_modules/@node-red/util/lib/util.js” from ‘init_commands’

1 Like

do not forget to update node-red-contrib-home-assistant-websocket

The update (version: 18.0.1) also started correctly for me after Removing “sed -i “772,775d” /opt/node_modules/@node-red/util/lib/util.js” from ‘init_commands’

THIS deserves way more upvotes. I just forgot about the initial command we had to add some months ago. Thanks!

Give credit where credit is due.

I did not apply the patch myself last year and could not make sense of the OP error message until @d_tech and @walberjunior posted, so they should get the credit. :smiley:

Does 18.0.3 correct this or does it still require the change to init commands? I don’t believe I ever entered that work around but didn’t want to find out after I updated if it can be avoided.

My understanding is the init command was a workaround for people who didn’t want to fix the issue “right”, and so is not anything that will be fixed. But I could be wrong.

FWIW I instralled 18.0.3 last night and had no issues (but I also had not edited the startup sequence).

If you have this command in your configuration, it needs to be removed. It was a temporary fix for a certain problem. If you are using the addon, goto the configuration tab on the addon page.

Scroll down to init commands, do you have an entry for sed -i “772,775d” /opt....? No you can upgrade without worrying about this. If it is there upgrade NR and then remove the command from the configuration and restart.