ERROR starting node red

17 Dec 17:38:15 - [info] Node-RED version: v3.0.2
17 Dec 17:38:15 - [info] Node.js version: v18.12.1
17 Dec 17:38:15 - [info] Windows_NT 10.0.19044 x64 LE
17 Dec 17:38:17 - [info] Loading palette nodes
17 Dec 17:38:17 - [error] Failed to start server:
17 Dec 17:38:17 - [error] TypeError: Cannot read properties of undefined (reading 'forEach')
at Object.addModule (C:\Users\myname\AppData\Roaming\npm\node_modules\node-red\node_modules@node-red\registry\lib\registry.js:195:27)
at C:\Users\myname\AppData\Roaming\npm\node_modules\node-red\node_modules@node-red\registry\lib\loader.js:153:34

What have you just done that may have triggered that? Perhaps you have just installed a new node-type.

I downloaded a working flow from one pc to a new Pc with a new installation of node red running on it. So the database node was flaged in red because such a database did not exist in the new PC. I created the database named readings in mysql and when I tried to edit the properties in the database node the node red server lost its connectivity and after that I could not restart node red or even edit what was on
screen.

Which database node are you using? The error you posted is caused by a badly behaved node that is not compatible with the latest node-red.

Did you re-install all the extra nodes manually, or did you copy the folder .node-red/node_modules across from the old one? If you copied node_modules then delete that folder and go into your .node-red folder and run
npm install

If still no joy then please post the file .node-red/package.json

[Edit] If you haven't done it yet, then if you also copied package-lock.json across then delete that file before running npm install. That will make sure it installs the latest versions of everything.

I did not copy any folders, the nodes were downloaded using palette manager.

I used the MySQL node. In fact when I first imported the flow the DB nodes were blank. Then when I downloaded the nodes through palette manager they were automatically selected to the flow, so I guess the system detected that t was the most appropriate thing.

Also is there a way to install node-red version 2?

Can you post the file package.json please from your .node-red directory. Then we can see which nodes you have installed and possibly identify the problematic one.

npm install -g --unsafe-perm node-red@a.b.c

Where a.b.c is the version you want to install

package.json (415 Bytes)
here we go bro . Hope this helps.

Pasting package.json inline so that it is easier to see

{
    "name": "node-red-project",
    "description": "A Node-RED Project",
    "version": "0.0.1",
    "private": true,
    "dependencies": {
        "dashboard-evi": "~1.0.2",
        "node-red-contrib-data-table-viewer": "~0.0.5",
        "node-red-contrib-tabletojson": "~1.0.3",
        "node-red-dashboard": "~3.2.3",
        "node-red-node-mysql": "~1.0.3",
        "node-red-node-ui-table": "~0.4.3"
    }
}

Are you using dashboard-evi? I would not be surprised if that is the problem.
If you want to remove it then go into your .node-red folder and run
npm remove dashboard-evi
then try starting node-red again.

yes I am using dashboard EVI. Just noticed the package. I deleted it and started node red again but I still get the same error.

Welcome to Node-RED

19 Dec 03:50:10 - [info] Node-RED version: v3.0.2
19 Dec 03:50:10 - [info] Node.js version: v18.12.1
19 Dec 03:50:10 - [info] Windows_NT 10.0.19044 x64 LE
19 Dec 03:50:12 - [info] Loading palette nodes
19 Dec 03:50:28 - [error] Failed to start server:
19 Dec 03:50:28 - [error] TypeError: Cannot read properties of undefined (reading 'forEach')
at Object.addModule (C:\Users\myname\AppData\Roaming\npm\node_modules\node-red\node_modules@node-red\registry\lib\registry.js:195:27)
at C:\Users\myname\AppData\Roaming\npm\node_modules\node-red\node_modules@node-red\registry\lib\loader.js:153:34
C:\Users\myname>

Delete isn't a good word to use about installed nodes. What exactly did you do?

If you start node red in safe mode does it start up ok? If it does make sure you have the latest versions of all nodes.
node-red --safe

I removed the node using the command you provided. However, the issue is still there even when I start it in safe mode. Cant I completely delete node-red and install version 2 ? if its a good move how do I do that.

It would be good if we could isolate the problem before downgrading node-red. Then others will not fall into the hole.

If possible first please check that dashboard-evi has disappeared from package.json. If it has then go into your .node-red folder and run
npm remove node-red-contrib-data-table-viewer
and
npm remove node-red-contrib-tabletojson
and check they have also gone from package.json.
Then restart node red and see if it is ok (apart from the fact that it complains about missing nodes). If it is then install one of those via the menu Manage Palette and restart node-red, and if still ok do the same with the other. Possibly that will tell us that one of those is the problem.

If you still need to downgrade node-red then you don't need to remove the current version, just install the earlier one using the command I posted, and restart node-red.

Those two nodes are very important to me, unless you have a good alternative. BTW the name of the database which the db node connects to is "readings"

Try removing those nodes in order to identify whether one of those is the problem. Once that is done you can reinstall (which will give you the latest versions) which may fix it (I notice one was updated a few days ago). If it doesn't fix it you can report the issue to the author and downgrade node red. If the node gets fixed then you can upgrade node red again.

I removed the two nodes yet still I get an error.

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

28 Dec 00:39:25 - [info] Node-RED version: v2.1.1
28 Dec 00:39:25 - [info] Node.js  version: v18.12.1
28 Dec 00:39:25 - [info] Windows_NT 10.0.19044 x64 LE
28 Dec 00:39:26 - [info] Loading palette nodes
28 Dec 00:39:54 - [info] Dashboard version 3.2.3 started at /ui
28 Dec 00:39:56 - [warn] Missing node modules:
28 Dec 00:39:56 - [warn]  - dashboard-evi (1.0.2): ui_base, ui_button, ui_dropdown, ui_switch, ui_slider, ui_numeric, ui_text_input, ui_date_picker, ui_colour_picker, ui_form, ui_text, ui_gauge, ui_chart, ui_audio, ui_toast, ui_ui_control, ui_template, ui_link, ui_tab, ui_group, ui_spacer
28 Dec 00:39:56 - [warn]  - node-red-contrib-data-table-viewer (0.0.5): table-viewer
28 Dec 00:39:56 - [info] Removing modules from config
28 Dec 00:39:56 - [error] Failed to start server:
28 Dec 00:39:56 - [error] TypeError: Cannot read properties of undefined (reading 'forEach')
    at removeNode (C:\Users\myname\AppData\Roaming\npm\node_modules\node-red\node_modules\@node-red\registry\lib\registry.js:236:18)
    at Object.cleanModuleList (C:\Users\myname\AppData\Roaming\npm\node_modules\node-red\node_modules\@node-red\registry\lib\registry.js:619:29)
    at C:\Users\myname\AppData\Roaming\npm\node_modules\node-red\node_modules\@node-red\runtime\lib\index.js:195:34

In post #10 you posted:

Now you have

What is going on?

Did you work out what is going on with this problem?

Hey Col sorry about the delay. So I tried downgrading as well but it did not work. Also even after removing the elements that you recommended I still get the same error.

Temporarily rename your .node-red folder to something else and restart node-red. That will restart node-red with an empty flows file. If that fails then your node-red install is messed up, so re-install it. If it is ok then you can import the flows again and try again.