What did you do that may have triggered that? Did you install a node or edit one of the files, for example?
Did you edit settings.js? If so, check to see if you missed a comma or a bracket.
If you can't find an error and haven't added anything that could comprimize your security, you could edit the file and copy it and paste it to a reply.
In order to make code more readable and importable it is important to surround your code with three backticks
```
like this
```
You can edit and correct your post by clicking the pencil icon.
See this post for more details - How to share code or flow json
@zenofmud this is not related to a typo in the settings file.
@AngelMx3 we do need a bit more information as @Colin has asked.
We have seen this error before, but it has always been due to a "bad" node being installed.
Nick, should he be able to start in safe mode (--safe)?
Hi did you work out how to resolve this I just upgraded node-red and on restarting I'm getting the same error message.
node-red
5 Aug 13:52:17 - [info]
Welcome to Node-RED
===================
5 Aug 13:52:17 - [info] Node-RED version: v2.0.5
5 Aug 13:52:17 - [info] Node.js version: v14.16.0
5 Aug 13:52:17 - [info] Windows_NT 10.0.18363 x64 LE
5 Aug 13:52:17 - [info] Loading palette nodes
5 Aug 13:52:17 - [error] Failed to start server:
5 Aug 13:52:17 - [error] TypeError: Cannot read property 'forEach' of undefined
at Object.addModule (C:\Users\blah\AppData\Roaming\npm\node_modules\node-red\node_modules\@node-red\registry\lib\registry.js:195:27)
at C:\Users\blah\AppData\Roaming\npm\node_modules\node-red\node_modules\@node-red\registry\lib\loader.js:153:34
i tried to restart with node-red --safe and get the same problem
What about the other questions that were asked on this thread? This error is always caused by a 'bad' node you have installed. I must admit I thought we'd squashed it once and for all in 2.x.
If you can identify what contrib node you've installed that is causing this, I'd love to see why it keeps escaping our attempts to handle it properly.
Apologies I've installed the product to start learning... not sure what a contrib node is? I'd tried earlier to install the rabbitmq package from within the node red application - this one I think amqp-ts.
I got a warning during the installation about compatibility so thought it would be a good idea to make sure i was on the latest node-red version.
What was the full name of the package you installed? It was likely node-red-contrib-<something>
- hence what we call contrib
nodes.
this one: node-red-contrib-amqp (node) - Node-RED and I installed it from within the manage pallette. install
ok... i fixed it. I added the debug that @knolleary had suggested in another post. Error loading node-red - #2 by Steve-Mcl
and it told me the following on start-up:
Path: C:\Users\<username>\.node-red\node_modules\node-red-contrib-amqp
I deleted that folder and everything in it... now starts up ok.
If you don't properly uninstall it then npm will reinstall it at some point.
Go to your .node-red folder and run
npm remove node-red-contrib-amqp
thanks @Colin I'd already run the remove command but the files were still there. The debug helped me find the left-over files as initially, I'd been looking in a different directory structure.
Hopefully that means its gone now
Something went wrong with the remove then. To make sure all is as it should be go into your .node-red folder and run npm install
and make sure it doesn't reinstall anything.
thanks, i've run it and got this output:
\.node-red>npm install
npm notice created a lockfile as package-lock.json. You should commit this file.
removed 21 packages in 0.52s
found 0 vulnerabilities
seems odd that it removed packages for an install. Is that it tidying up further? Is there a way of checking what is installed with npm. To my knowledge I've only ever installed node-red and the amqp contrib that seems to have caused the problem with restarts.
How have you been installing packages so that you did not have a package lock file?
sorry @Colin not sure i understand the question.
Initially I installed node-red just following the instructions on the site: Running Node-RED locally : Node-RED
The package that seems to have broken things I installed using the "manage pallette" option:
and:
By running npm install
, npm uses your package.json file as the list of what should be installed. Any modules not listed in your package.json file, or not in the dependency tree of the listed modules, will get removed.
Because you removed the amqp module by deleting it's folder, you would have left behind all of its dependencies. Those will be the modules it reported as removed when you ran npm install.
I would have expected amqp to have still been in package.json and I would have expected the lock file to already exist.