Failed to start server ... registry.js:195:27

Hi,
i could not start my node-red server again. Getting the following error. Using node-red on windows. Hopefully anybody can help me. Is there a list or something where i can disable additional installed nodes ? Where are my flows saved? Maybe i can remove them to get the server starting again.
[info] Loading palette nodes
2 May 17:47:15 - [error] Failed to start server:
2 May 17:47:15 - [error] TypeError: Cannot read properties of undefined (reading 'forEach')
at Object.addModule (C:\Users\steve\AppData\Roaming\npm\node_modules\node-red\node_modules@node-red\registry\lib\registry.js:195:27)
at C:\Users\steve\AppData\Roaming\npm\node_modules\node-red\node_modules@node-red\registry\lib\loader.js:153:34

Welcome the forums @steve1.

This is your first post.
So when you say: i could not start my node-red server again

What do you mean "again" ? can you give us (a lot) more info, on what you have done leading upto this error?

  • How are you starting Node RED
  • Did you install any nodes before this error occurred
  • Node Version
  • Node RED version

Also, this
C:\Users\steve\AppData\Roaming\npm\node_modules\node-red\node_modules@node-red\registry\lib\loader.js

seems incorrect, it should be (node_modules\@node-red, not node_modules@node-red), but then I dont use windows so maybe normal :man_shrugging:

C:\Users\steve\AppData\Roaming\npm\node_modules\node-red\node_modules\@node-red\registry\lib\loader.js

if you can detail your setup, it may help us to understand what is going on.

I'm starting the server using the 'cmd'. Node-red was running for few weeks, today i worked on it, added also a new node (not sure how it was named, something with table ui or so) and got an error ..."is already installed" or similar, but was not. I went on to work on an other issue. By using 'deploy' the connection to the server was lost, i tried to restart it, but only got the error.
[info] Node-RED version: v3.0.2
2 May 17:47:13 - [info] Node.js version: v18.10.0
2 May 17:47:13 - [info] Windows_NT 10.0.19044 x64 LE
2 May 17:47:15 - [info] Loading palette nodes
2 May 17:47:15 - [error] Failed to start server:
2 May 17:47:15 - [error] TypeError: Cannot read properties of undefined (reading 'forEach')
at Object.addModule (C:\Users\steve\AppData\Roaming\npm\node_modules\node-red\node_modules@node-red\registry\lib\registry.js:195:27)
at C:\Users\steve\AppData\Roaming\npm\node_modules\node-red\node_modules@node-red\registry\lib\loader.js:153:34
It's 'C:\Users\steve\AppData\Roaming\npm\node_modules\node-red\node_modules''@node-red\registry\lib\loader.js' on some reason after posting it's removing the '' from the post...

Node-red was running for a few weeks. Today, I was working on it. I also installed new node, not sure if it was 'table ui' or something. I got an error similar to 'already installed' but wasn't. Ignored it and was working on an other issue. Lateron that day, server lost connection after 'deploy'. So I want to restart (using 'cmd'), but only got this error.
<2 May 17:47:13 - [info] Node-RED version: v3.0.2
2 May 17:47:13 - [info] Node.js version: v18.10.0
2 May 17:47:13 - [info] Windows_NT 10.0.19044 x64 LE
2 May 17:47:15 - [info] Loading palette nodes
2 May 17:47:15 - [error] Failed to start server:
2 May 17:47:15 - [error] TypeError: Cannot read properties of undefined (reading 'forEach')
at Object.addModule (C:\Users\steve\AppData\Roaming\npm\node_modules\node-red\node_modules@node-red\registry\lib\registry.js:195:27)
at C:\Users\steve\AppData\Roaming\npm\node_modules\node-red\node_modules@node-red\registry\lib\loader.js:153:34 />

I'm not a core developer for Node RED - They are around of course, so I can only advise,
"what I would do"

Re-install Node RED

npm install -g --unsafe-perm node-red

(or however you installed initially)

This won't remove any nodes you have, but back them up just in case, and re-install nodes that are missing via the palette menu.

I have never really seen an error of this nature

Thx, tried the re-installed. Did not work, same error. :cold_sweat:

what happens if you run Node RED with the argument --safe
it could well be a node that is causing issues

same error

does this directory actually exist?

or does it exist as

C:\Users\steve\AppData\Roaming\npm\node_modules\node-red\node_modules\@node-red

This is correct, when c&p error msg into browser and posting it, the '' is removed. So this should not be the problem.

What does....

C:\Users\steve\AppData\Roaming\npm\package.json contain.

also do npm list -g - what does that show

EDIT:
I should state, my knowledge is being stretched at this point (Mainly, with Windows) :sweat_smile:

used a debug insertion I currently found in the forum. Got the following error msg:

May 19:42:59 - [info] Node-RED version: v3.0.2
2 May 19:42:59 - [info] Node.js version: v18.10.0
2 May 19:42:59 - [info] Windows_NT 10.0.19044 x64 LE
2 May 19:43:01 - [info] Loading palette nodes
Module: node-red-contrib-tabletojson
Path: \Users\steve.node-red\node_modules\node-red-contrib-tabletojson
Set: version
2 May 19:43:01 - [error] Failed to start server:
2 May 19:43:01 - [error] TypeError: Cannot read properties of undefined (reading 'forEach')
at Object.addModule (C:\Users\steve\AppData\Roaming\npm\node_modules\node-red\node_modules@node-red\registry\lib\registry.js:202:27)
at C:\Users\steve\AppData\Roaming\npm\node_modules\node-red\node_modules@node-red\registry\lib\loader.js:153:34

So maybe 'tabletojson' is not working. I'm trying to uninstall...
Edit: used: npm uninstall node-red-contrib-tabletojson
Got same error after starting the server...

What does

C:\Users\steve\AppData\Roaming\npm\package.json contain?

package.json is not in that folder, but consists:

{
"name": "node-red",
"version": "3.0.2",
"description": "Low-code programming for event-driven applications",
"homepage": "http://nodered.org",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "GitHub - node-red/node-red: Low-code programming for event-driven applications"
},
"main": "lib/red.js",
"scripts": {
"start": "node red.js"
},
"bin": {
"node-red": "./red.js",
"node-red-pi": "bin/node-red-pi"
},
"contributors": [
{
"name": "Nick O'Leary"
},
{
"name": "Dave Conway-Jones"
}
],
"keywords": [
"editor",
"messaging",
"iot",
"flow"
],
"dependencies": {
"@node-red/editor-api": "3.0.2",
"@node-red/runtime": "3.0.2",
"@node-red/util": "3.0.2",
"@node-red/nodes": "3.0.2",
"basic-auth": "2.0.1",
"bcryptjs": "2.4.3",
"express": "4.18.1",
"fs-extra": "10.1.0",
"node-red-admin": "^3.0.0",
"nopt": "5.0.0",
"semver": "7.3.7"
},
"optionalDependencies": {
"bcrypt": "5.0.1"
},
"engines": {
"node": ">=14"
}
}

This looks maybe like 'default' from re-install?!

Short of removing Node RED entirely (and its components), and reinstalling fresh, I'm a little out of ideas.

Your flows should remain if doing this.

OR

What for someone more close to the core, to chip in :sweat_smile:

Is there an easy way to remove it completly by using command line?

Not being a Windows user:

npm uninstall [-g] node-red -g if you installed globally

then check

C:\Users\steve\AppData\Roaming\npm\node_modules\node-red

is gone

Uninstalled. Folder was gone. Reinstalled, same problem... Is there any other folder where data could be left over?

Ok, go here.

C:\Users\Steve\.node-red

and do npm list <- what's the output.

```
here
```

This was a good hint...
C:\Users\steve.node-red>npm list
node-red-project@0.0.1 C:\Users\steve.node-red
+-- node-red-contrib-iiot-opcua@4.0.11
+-- node-red-contrib-opcua@0.2.289
+-- node-red-contrib-tabletojson@1.0.3
+-- node-red-mysql-r2@1.3.0
`-- node-red-node-ui-table@0.4.3

Found another package.js in which the mayby faulty 'tabletojson' is in:
{
"name": "node-red-project",
"description": "A Node-RED Project",
"version": "0.0.1",
"private": true,
"dependencies": {
"node-red-contrib-iiot-opcua": "~4.0.11",
"node-red-contrib-opcua": "~0.2.289",
"node-red-contrib-tabletojson": "~1.0.3",
"node-red-mysql-r2": "~1.3.0",
"node-red-node-ui-table": "~0.4.3"
}
}
Can i just remove it from here?