Stop and start node red programmatically

I have embedded nodered in electron app.
Have started the node red. ( programmatically using RED.start()), now i want to restart it.
trying to use RED.stop.then(()=>RED.start());
it is giving error like
Potentially unhandled rejection [1] TypeError: Cannot read property 'forEach' of undefined
at Object.addModule (...\node_modules@node-red\registry\lib\registry.js:199:27)
It seems it is trying to load opcua node modules and it is giving this error.

When node red started first time programmatically, i didn't get this error, when i stop and then start I get this error.

Can idea how to handle this

  • Any other way to restart node red programmatically?
  • Am i doing anything wrong? please correct me
1 Like

The RED.stop/start API does not currently work well with doing multiple restarts of the the runtime without also restarting the Node.js process. It just isn't the primary use case as Node-RED is normally a self-contained long running process.

It would be good to get it working - but I suspect it will need more testing and development work to get it working.

2 Likes

Hey,
I just encountered a similar problem and was wondering if the API now supports this functionality (restarting without restarting the Node.js process).