Node development: troubleshooting process?


I'm getting started on my first node; I'm basically in the hello world phase right now. I've been running into a ton of different issues with getting the node to load and behave properly. The biggest thing I'm running into is that I'm not seeing any errors, neither in the browser's developer console nor in the console output from the server.

FWIW: the most recent issue I'm having is that I can't get the node's label to update; it doesn't seem to be executing the function for the label more than once on load.


If you are using vscode as your IDE you can use the build in debugger. For client side debugging use the browsers debugger.
Very powerful tools.

In your case place the debugger; statement where the update should happen. But likely it will never trigger. These problems are hard to debug because there is no real error to catch when your code isn’t executed at all.

And BTW welcome to the forum.

1 Like

the Node's label is not dynamic - it is only set on load.

I was wondering about that for a while, but looking at other nodes, it seems very common to use something like:
label: () => || '<node_type>',

Also, changing the name of some of the default nodes results in their label changing.

You cannot use arrow functions if you want to use this to reference the node.

You define a proper function:

label: function () { return || 'node-type' }
1 Like

That was it. Thanks! Is this something intrinsic to Javascript that I've overlooked, or is it specific to Node-Red?

It's a feature of JavaScript arrow functions. One of the edge cases when they shouldn't be used.

Got it. MDN sums it up pretty well here*:

An arrow function expression is a syntactically compact alternative to a regular function expression, although without its own bindings to the this , arguments , super , or keywords. Arrow function expressions are ill suited as methods, and they cannot be used as constructors.

Hopefully eslint will spot things like that if I can get it to look inside of the HTML.


1 Like