Have a JSON error

HI Guys,

I am having an error on a block and i quite can’t figure it out. Maybe you guys can find it, can you please review the script?

Screenshot 2024-11-05 at 12.29.55 PM

With the newer versions of Node-RED (3.0 and newer, off the top of my head) the default editor for function nodes is “monaco” instead of the older “ace”.
A side affect of this is that it will error out when you don’t explicitly define new variables, like on line 2 you have var d = .. but on line 1 you just say file = ..

This doesn’t affect message properties like msg.topic = .. since the msg object is already defined, but does matter for local variables like file.
If you add var file = , let file = , or const file = it will clear the error on line 1 and you should be good to go.

Can you give that a try and let us know if that gets it going?


EDIT: I typically use var out of habit, but if you want some guidance on when / why to use let or var to define new variables, this post breaks it down with some more specific examples.
TL;DR — just use let to avoid weird behavior.

2 Likes

Awesome, Var File made the trick.

thank you so much

2 Likes