Windows 10 [error] Failed to start server: [error] TypeError: Cannot read property

After new install I get this.....
Anybody know how to fix this......

C:>node-red
29 Nov 10:58:28 - [info]

Welcome to Node-RED

29 Nov 10:58:28 - [info] Node-RED version: v1.0.3
29 Nov 10:58:28 - [info] Node.js version: v12.13.1
29 Nov 10:58:28 - [info] Windows_NT 10.0.18362 x64 LE
29 Nov 10:58:28 - [info] Loading palette nodes
29 Nov 10:58:29 - [error] Failed to start server:
29 Nov 10:58:29 - [error] TypeError: Cannot read property 'forEach' of undefined
at Object.addModule (C:\Users\AS\AppData\Roaming\npm\node_modules\node-red\node_modules@node-red\registry\lib\registry.js:186:27)
at C:\Users\AS\AppData\Roaming\npm\node_modules\node-red\node_modules@node-red\registry\lib\loader.js:108:30
at tryCatchReject (C:\Users\AS\AppData\Roaming\npm\node_modules\node-red\node_modules\when\lib\makePromise.js:845:30)
at runContinuation1 (C:\Users\AS\AppData\Roaming\npm\node_modules\node-red\node_modules\when\lib\makePromise.js:804:4)
at Fulfilled.when (C:\Users\AS\AppData\Roaming\npm\node_modules\node-red\node_modules\when\lib\makePromise.js:592:4)
at Pending.run (C:\Users\AS\AppData\Roaming\npm\node_modules\node-red\node_modules\when\lib\makePromise.js:483:13)
at Scheduler._drain (C:\Users\AS\AppData\Roaming\npm\node_modules\node-red\node_modules\when\lib\Scheduler.js:62:19)
at Scheduler.drain (C:\Users\AS\AppData\Roaming\npm\node_modules\node-red\node_modules\when\lib\Scheduler.js:27:9)
at processTicksAndRejections (internal/process/task_queues.js:75:11)

Welcome to the Node-RED community.

That's a strange error.

My first guess would be that you have an error either in your settings.js file or in your flows.

Try starting Node-RED with the --safe parameter to see if that helps. If not, try renaming your settings.js file and restarting - you might have to copy a clean version from the node-red master, I can't quite remember if it copies it over automatically.

I have the same error, lucky arnt we

Are you getting exactly the same error, if not then please start a new thread as it is a different problem.
If you are then did the suggestions from the previous post help? Since the OP did not have the courtesy to reply I assume it did, or he realised he was doing something silly.

basically failed to start server?

PS C:\WINDOWS\system32> node-red.cmd
25 Feb 11:42:00 - [info]

Welcome to Node-RED

25 Feb 11:42:00 - [info] Node-RED version: v1.0.3
25 Feb 11:42:00 - [info] Node.js version: v12.16.1
25 Feb 11:42:00 - [info] Windows_NT 10.0.18363 x64 LE
25 Feb 11:42:02 - [info] Loading palette nodes
25 Feb 11:42:02 - [error] Failed to start server:
25 Feb 11:42:02 - [error] TypeError: Cannot read property 'forEach' of undefined
at Object.addModule (C:\Users\Dell\AppData\Roaming\npm\node_modules\node-red\node_modules@node-red\registry\lib\registry.js:186:27)
at C:\Users\Dell\AppData\Roaming\npm\node_modules\node-red\node_modules@node-red\registry\lib\loader.js:108:30
at tryCatchReject (C:\Users\Dell\AppData\Roaming\npm\node_modules\node-red\node_modules\when\lib\makePromise.js:845:30)
at runContinuation1 (C:\Users\Dell\AppData\Roaming\npm\node_modules\node-red\node_modules\when\lib\makePromise.js:804:4)
at Fulfilled.when (C:\Users\Dell\AppData\Roaming\npm\node_modules\node-red\node_modules\when\lib\makePromise.js:592:4)
at Pending.run (C:\Users\Dell\AppData\Roaming\npm\node_modules\node-red\node_modules\when\lib\makePromise.js:483:13)
at Scheduler._drain (C:\Users\Dell\AppData\Roaming\npm\node_modules\node-red\node_modules\when\lib\Scheduler.js:62:19)
at Scheduler.drain (C:\Users\Dell\AppData\Roaming\npm\node_modules\node-red\node_modules\when\lib\Scheduler.js:27:9)
at processTicksAndRejections (internal/process/task_queues.js:79:11)

PS C:\WINDOWS\system32>

@dougcr4 Doug, try keeping your postings to 1 specific topic. You're now posting about this exact issue in 3, if not 4 different topics. It's far easier to help you if you keep it all in one place, and answer the questions you were asked there.

OK, Ive never used a forum before

Hi @dougcr4

this is a rare issue that we've never managed to get to the root cause of.

If you are still hitting it, could I trouble you to add a bit of debug into the code to help us figure it out?

Specifically, if you edit the file C:\Users\Dell\AppData\Roaming\npm\node_modules\node-red\node_modules@node-red\registry\lib\registry.js and look at line 186 you should see:

                set.types.forEach(function(t) {
                    if (nodeTypeToId.hasOwnProperty(t)) {

Please add the following immediately before it:

                // START DEBUG
                if (!set.types) {
                    console.log("Module:",module.name);
                    console.log("Path:",module.path);
                    console.log("Set:",setName);
                }
                // END DEBUG
                set.types.forEach(function(t) {
                    if (nodeTypeToId.hasOwnProperty(t)) {

The next time you restart Node-RED you'll get a bit more information in the log about what node module its loading when it hits the error

4 Likes

Well Nick. After over 30 hours from the last 48 messing, trying to get note red running ( and never used a forum before,,,). I needed to get this node red install and a few tutorials under the belt and crossed off the list. The only answer left was a Ubuntu partition or off a dvd finally yeap, sorted that for sure...

I can still get into the windows Environment but only through the task manager and then running a new task with either cmd or power shell ah ha and getting the c prompt. all looks fine but laptop now is just a chocolarty saucepan. Lol should have gone to bed at 17:30,

However in the last 30 minutes i got the old PC from the damp shed and configured the network, made a cup of tea and installed node red. You are sureley welcome to any files from the DELL laptop, just have to give me a day or so to sort it out

My thoughts, not trying to interfere in your work or your own system preferences, is only this.

I never use Windows NT for anything; and run Node-RED (currently) on four Ubuntu Linux servers and one macOS dev box on my desktop, and I am very impressed with Node-RED. The install works smooth and is well documented.

In my personal view only, if you love Node-RED and want to do great things with it, run it on Linux :slight_smile: Some people even run NR on the PI. I run NR on a handful of Linux servers and on one macOS server, and have never have a problem with installing, adding modules, etc.

Smooth as butter....

Sorry, if this is potentially offensive or off topic, but Windows NT is not "my thing" and Linux works so great and is so inexpensive. I've been having a few "bad day" in one of my data centers (as a customer) so apologies for "telling the naked truth"... I do realize that there are many folks who want Node-RED on various windows platforms, so I sincerely apologize for speaking my personal opinion and possibly offending any good person with Windows who "have no choice".....

Node-RED runs smooth as butter on Linux and macOS, for the most part. Very impressive.

OS related issues can appear on any platform. NR dev-master's made in a such a phenomenal way that it runs almost anywhere. You could use docker instead or even opt for a vm on windows running linux, but windows should work natively as well. Hopefully it can be sorted out one day.

Some people even run NR on the PI

Make that: most people

Just to get you going on your original machine - you could use NodeRED desktop.

It's not "official" but its worked for me with every WIn10 machine I've installed it on (a bunch of school laptops)

Note - it hides some of the core nodes (MQTT in particular) but these are easily restored by just removing them from the exclusion list in the settings

That's OK, he is using Windows 10 :grinning:

And it normally does on Windows too. But as backman2 say's, these things can happen on any OS. Truth is that our general purpose OS's are wackily complex right? So it is fairly inevitable that things go wrong from time-to-time.

If Doug can come back with the info that Nick has requested, hopefully the issue will get fixed. Most likely some odd OS configuration issue or a corrupt file.

BTW and slightly off-topic, while I generally agree that running services, especially Node.js or similar or web services is best done on Linux, Windows works perfectly well too and is a preferred development environment for many people including myself. The joy of working with Node.JS is that it is pretty good at being cross-platform for nearly everything.

Hello
I am having the very same problem on a Windows 10 PC. I have added the debug lines to the registry.js file.
Below is the log after starting NodeRed. I hope it can be of help

C:\Users\Riccardo\appdata\roaming\npm\node_modules\node-red\node_modules> node-red
23 Sep 00:01:20 - [info]

Welcome to Node-RED

23 Sep 00:01:20 - [info] Node-RED version: v1.1.3
23 Sep 00:01:20 - [info] Node.js version: v12.15.0
23 Sep 00:01:20 - [info] Windows_NT 10.0.18363 x64 LE
23 Sep 00:01:24 - [info] Loading palette nodes
23 Sep 00:01:27 - [error] Failed to start server:
23 Sep 00:01:27 - [error] TypeError: Cannot read property 'forEach' of undefined
at Object.addModule (C:\Users\Riccardo\AppData\Roaming\npm\node_modules\node-red\node_modules@node-red\registry\lib\registry.js:186:27)
at C:\Users\Riccardo\AppData\Roaming\npm\node_modules\node-red\node_modules@node-red\registry\lib\loader.js:108:30
at tryCatchReject (C:\Users\Riccardo\AppData\Roaming\npm\node_modules\node-red\node_modules\when\lib\makePromise.js:845:30)
at runContinuation1 (C:\Users\Riccardo\AppData\Roaming\npm\node_modules\node-red\node_modules\when\lib\makePromise.js:804:4)
at Fulfilled.when (C:\Users\Riccardo\AppData\Roaming\npm\node_modules\node-red\node_modules\when\lib\makePromise.js:592:4)
at Pending.run (C:\Users\Riccardo\AppData\Roaming\npm\node_modules\node-red\node_modules\when\lib\makePromise.js:483:13)
at Scheduler._drain (C:\Users\Riccardo\AppData\Roaming\npm\node_modules\node-red\node_modules\when\lib\Scheduler.js:62:19)
at Scheduler.drain (C:\Users\Riccardo\AppData\Roaming\npm\node_modules\node-red\node_modules\when\lib\Scheduler.js:27:9)
at processTicksAndRejections (internal/process/task_queues.js:76:11)

It doesn't say much to me. Node-Red is unusable.
If it can be of help I can give you access to my PC in order for you to solve this bug.
Thank you in advance.

Riccardo

Have you tried starting in safe mode?

If that doesn't work, try renaming your ~/.node-red folder and restarting Node-RED.

That should eliminate issues related to loaded nodes, settings. and to any flows.

If you are then still having issues, completely remove Node-RED and check C:\Users\Riccardo\AppData\Roaming\npm\ to make sure nothing is left behind.

After that, reinstall Node-RED. But first make sure you have installed build-essentials globally. When installing globally, try without an elevated command prompt first, if that doesn't work, open a command prompt as administrator.

It is something local to your machine since many of us are successfully using Node-RED.

If after all that you are still stuck, I would remove Node-RED again and this time install locally. Create a convenient folder and install NR. My alternate installer repo can be used if you like or at least will give you the info on how to do it.

1 Like

Hey Knolleary

Thanks a lot for this nice debugging trick! I could fix the problem with it.:+1::grinning:

Bests
Reza

@knolleary
Thanks a lot. For me, it showed the module causing problem and I removed its dependency from ~.node-red/package.json and restarted Node RED server and it worked.

1 Like

After addind the DEBUG line I'm getting the details as follows. Can anyone help what should be done next?

SyntaxError: missing ) after argument list
at wrapSafe (internal/modules/cjs/loader.js:1001:16)
at Module._compile (internal/modules/cjs/loader.js:1049:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:14)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:92:18)
at Object. (C:\Users\Sahil\AppData\Roaming\npm\node_modules\node-red\node_modules@node-red\registry\lib\index.js:27:16)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)

New thread started.

Closing this one.