Node installed but not showing up in palette

Hi there!

After updating to Node-RED 1.0.0, one of my nodes (suncron) does not show up in the palette anymore. The package does show as installed in the package manager and the logs do not contain any hints.

Any ideas what the problem is? Thank you!

did you try removing it and adding it back in?

yes, same effect :frowning:

Did you check your log and/or try and install it va the cli?
I jut installed it via the palette manager and it showed up fine.
Maybe a conflict with another node??

The log just shows that the node was registered. No errors. I tried re-installing via CLI and palette manager without success. If there was a conflicting node, I would expect some hint in the logs, right? Or how can I debug this further?

Can you check the browser's javascript console for any errors?

@knolleary, bingo!

Uncaught SyntaxError: Identifier 'calcDuration' has already been declared

This is at least pointing somewhere...

Does this mean another node or even the node-red runtime is making use of the same identifier? Collision by accident? But I would expect that each node has its own scope, no?

i don't think it's anywhere in the Node-RED code... (at least that is what grep tells me)...
More likely there are two instances of this node installed and it is conflicting with itself... - did one get installed as root/globally by any chance ?

No. That isn't possible. We no longer load two copies of the same node.

My guess is this node started life as a copy of an existing nodes code base and they both declare this variable as a global - which is bad practice regardless.

The question is which node is it clashing with.

Once approach to narrow it down would be to open http://localhost:1880/nodes in a new browser tab. You'll get a largely blank page. Then view source of the page and search for calcDuration. If you find it, scroll up to find the section break telling you which node that bit of code is from... Hopefully you'll see what I mean.

1 Like

so if it's 3rd party nodes then maybe ?

cd ~/.node-red/node_modules
grep -rl calcDuration *

should print the names of any files containing it.

Exactly that was the problem! I fixed it by surrounding the javascript part of the node HTML file with an immediately invoked function expression (IIFE), which adds the missing scoping to allow both nodes to co-exist.

Still interesting that this only became an issue with the update to v1.0.0, so I guess the Node-RED behavior changed?!

Thanks for all your support! Much appreciated!

Regardless of why, I find this encouraging actually. Because it is likely that improved coding practices are driving out other mistakes and forcing them to be fixed. Who knows what kind of odd effects such a code issue may have had - now gone. :slight_smile: