nodesDir crashes Node-RED 3.0?

Hello,

I’m developing custom nodes in a directory specified with the nodesDir property in the settings.js file. This set-up used to work up to Node-RED 2.2.2. However, I’ve just upgraded to Node-RED 3.0.2 and now the server crashes immediately on start-up, using a settings.js file that used to work before the upgrade.

Here is the start-up log:

Welcome to Node-RED
===================
1 Sep 20:18:04 - [info] Node-RED version: v3.0.2
1 Sep 20:18:04 - [info] Node.js  version: v16.17.0
1 Sep 20:18:04 - [info] Linux 5.10.0-9-amd64 x64 LE
1 Sep 20:18:04 - [info] Loading palette nodes
1 Sep 20:18:04 - [debug] Module: varenne-nodes 1.0beta1 /home/node-red/varenne-nodes
1 Sep 20:18:04 - [error] Failed to start server:
1 Sep 20:18:04 - [error] TypeError: Cannot read properties of undefined (reading 'forEach')
    at Object.addModule (/usr/lib/node_modules/node-red/node_modules/@node-red/registry/lib/registry.js:195:27)
    at /usr/lib/node_modules/node-red/node_modules/@node-red/registry/lib/loader.js:153:34

However, if I just remove the following line from my settings.js file, then Node-RED 3.0.2 will start normally ... but of course without my custom nodes.

nodesDir: '/home/node-red/varenne-nodes'

Could it be a regression with Node-RED 3.0 ? Or something specific to my environment ?

Any help will be appreciated.

Are you sure it is exactly that line you remove? Could you show us that section of the file with that line present?

Hi @lhp

Some of the logic around nodesDir did change in 3.0 - but should have been backwards compatible.

Can you raise an issue so we can investigate?

Hello,

I've created a GitHub issue to describe my problem

To given your more context, here are the settings.js files that I use; minus some values which have been redacted for obvious reasons.

https://www.celtrio.com/varenne/node-red/ok-settings.js
https://www.celtrio.com/varenne/node-red/ko-settings.js

The first settings.js works fine with Node-RED 3.0.2. The second file crashes the server on start-up. The only difference is the presence of the nodesDir property in the second file.

So the line you took out is actually
nodesDir: '/home/node-red/varenne-nodes',
which is not quite what you said. Had you not removed the trailing comma then I would have expected it to fail, though not in the way you said. Since you have also removed the comma then there does appear to be an issue.
It would probably be worth correcting the issue on github, just to avoid confusion.

Hello @Colin,

Thank you for looking into my problem. Unfortunately, the problem is not a syntax error in settings.js.

If I move my custom nodes from nodesDir to the default ./node-red/nodes ... then Node-RED will start normally, with my custom nodes. This looks like a regression with Node-RED 3 on the nodesDir setting.

I've updated the GitHub issue with this new information.

@lhp can you respond to the questions on the issue please? I would like to get the the bottom of this. Thanks for the feedback.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.