While learning how to write node code, I came across an error, that I did not understand. The error message in the log referenced that I had a type that was already registered?
For example the following generates the error... Node function name was 'si'...
RED.nodes.registerType("si",si);
But the following does not... Node function name was siNode of course...
RED.nodes.registerType("si",siNode);
Not understanding how a function name would conflict with a registered type? I take it this is something with the native to NR design or even node js? I found the documentation reference to how HTML and JS files link via the register type definition, but not how the function name in the js file would conflict with same.
I can't see how the function name has any bearing at all. The only thing that will cause the issue you describe is if RED.nodes.registerType is called more than once with "si" as its first argument.
So the error message maybe a bit misleading? But the fix, really was making sure the node function name was not the same as the registered type label/name. I see the same thing in many examples of node red modules, the registered type name is 'X' and the actual function name is 'XNode' for example. Even the official documented example uses 'lower-case' as the registered type, and the actual function name is 'LowerCaseNode'. They are never the same it appears.
Ah, ok... either way it was a rookie mistake, what I did. I went back and make sure my naming of types and functions as correct, and the issue resolved. Just seemed odd to me, but I am new to custom node development, so still tripping over stuff, as I learn.
Yeah, but to fix it... all I did was a 'Node' to the function name. But either way, discussed and done. I should have named the function better anyway, to match what is the common practice type of thing.