My setup: Node-RED user independent install to c:\ProgramData\npmglobal and c:\ProgramData.node-red
Startup via PM2-windows-service, but delay also accurs if Node-RED ist started manually on CLI
I have same experiences with one of my PC-s. Tried to find reasons but no luck for now. Sometimes the startup time is even more than minute. And that machine is much more powerfull than my others. I guess the corporate security settings might have some affections but that sort of things are unreachable for me in all means. So I accepted that slow start on that PC as others behave well enought.
With Process Monitor I found: C:\Users\{username}\AppData\Roaming\npm\node_modules\node-red\node_modules\proxy-addr\node_modules gets result NAME NOT FOUND
Running Node-RED behind corporate proxy. Tried to fix with help of goolge but no luck yet.
Startup times should be less than that of an equivalent setup on a Pi of course - unless you have a lot of other things going on.
Obvious place to start is to monitor disk and CPU activity during startup. I've had a PC in the past with a hybrid hdd/sdd that insisted on pausing every now and again due to a badly concocted disk interface.
Next place I'd look is at any node that relies on the network. Long pauses are often due to TCP timeouts so check if a node is looking for a network resource when it starts up. This might well account for different startup times in different locations - e.g. home vs corporate network.
If general monitoring can't help. Try using a NodeJS debugging monitor. The VScode editor can be configured to do detailed debugging of NodeJS apps and I've written about that previously.
My own PC is used for development and only takes a few seconds to start. I typically don't have a lot of big flows but even when I have, it doesn't take long to start.
This is a delay before Node-RED has loaded the flows - so won't be related to anything your flow is doing.
8 Oct 21:58:32 - [info] Windows_NT 10.0.17134 x64 LE
8 Oct 21:58:46 - [info] Loading palette nodes
The main activity Node-RED is doing between these two log statements is scanning the file system for node-red nodes to load - so is heavily dependent on disk access.
I'm slightly surprised it would take 3 minutes ... that's the sort of speed we'd get on an original Pi with slow SD Card access.
Hey, I experienced a similar issue on some computers in my former company. I'm not sure this is the same reason, but I think i should share my experience just in case...
I found out that the launcher hung in a loop that is in a script located at C:\Program Files\nodejs\npm.cmd
:: Created by npm, please don't edit manually.
@ECHO OFF
SETLOCAL
SET "NODE_EXE=%~dp0\node.exe"
IF NOT EXIST "%NODE_EXE%" (
SET "NODE_EXE=node"
)
SET "NPM_CLI_JS=%~dp0\node_modules\npm\bin\npm-cli.js"
FOR /F "delims=" %%F IN ('CALL "%NODE_EXE%" "%NPM_CLI_JS%" prefix -g') DO (
SET "NPM_PREFIX_NPM_CLI_JS=%%F\node_modules\npm\bin\npm-cli.js"
)
IF EXIST "%NPM_PREFIX_NPM_CLI_JS%" (
SET "NPM_CLI_JS=%NPM_PREFIX_NPM_CLI_JS%"
)
"%NODE_EXE%" "%NPM_CLI_JS%" %*
I didn't dig deeper into the issue, so I don't have any real fix, but a workaround : I removed the loop and it just worked in my case.
:: Created by npm, please don't edit manually.
@ECHO OFF
SETLOCAL
SET "NODE_EXE=%~dp0\node.exe"
IF NOT EXIST "%NODE_EXE%" (
SET "NODE_EXE=node"
)
SET "NPM_CLI_JS=%~dp0\node_modules\npm\bin\npm-cli.js"
"%NODE_EXE%" "%NPM_CLI_JS%" %*
I faced the same problem when the node-red run in a proxy network. while starting node-red NodeJs check for update information and this TCP communication is getting blocked.
As a workaround we can comment 'updateNotifier.checkNpm()' method calling part in the "C:\Program Files\nodejs\node_modules\npm\node_modules\update-notifier\check.js" file