# Node-Red 3 complains about me

**URL:** <https://discourse.nodered.org/t/node-red-3-complains-about-me/67804>\
**Category:** General\
**Created:** [16 September 2022 12:47 UTC](https://discourse.nodered.org/t/node-red-3-complains-about-me/67804 "2022-09-16T12:47:18Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Becker](https://avatars.discourse-cdn.com/v4/letter/b/c77e96/32.png) [@Becker](https://discourse.nodered.org/u/Becker)\
**Post date:** [16 September 2022 12:47 UTC](https://discourse.nodered.org/t/node-red-3-complains-about-me/67804/1 "2022-09-16T12:47:18Z")

</div>

Hi,  
i installed Node-Red 3 on both of my RPi.  
Just on one of them Node-Red complains about my functions:

 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/6/c6368a33bc1b7f342cc56cbf8815c54c7650002c.png)  
for example. Every function it complains something...

on the other RPi (same code) Node-Red does´t complain anything.

I don´t found an option to enable/disable complaining.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [16 September 2022 12:49 UTC](https://discourse.nodered.org/t/node-red-3-complains-about-me/67804/2 "2022-09-16T12:49:50Z")

</div>

> [@Becker](#):
>
> I don´t found an option to enable/disable complaining.

There is a way but this is literally telling you you have "bad" code.

Declare your variables with `const` or `let` and they will be fixed.  
`const` if it doesnt get changed, `let` if it does.

If you hover the red squiggle it tells you what is wrong.  
If you click the light bulb it offers solutions (not always perfect, but it tries)

---

<div class="post-metadata">

**Author:** ![Becker](https://avatars.discourse-cdn.com/v4/letter/b/c77e96/32.png) [@Becker](https://discourse.nodered.org/u/Becker)\
**Post date:** [16 September 2022 12:53 UTC](https://discourse.nodered.org/t/node-red-3-complains-about-me/67804/3 "2022-09-16T12:53:13Z")

</div>

Thx, I unterstand with const / let.  
But this does not answere my question: why is the other Pi with NR3 not complaining? Is there a switch?

I used "var Pth =..." before, but without "var" it worked too... so I deleted all "var" to reduce my code.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [16 September 2022 12:57 UTC](https://discourse.nodered.org/t/node-red-3-complains-about-me/67804/4 "2022-09-16T12:57:17Z")

</div>

Older node-red uses ACE editor. From version 3, Monaco editor is the default - and for good reason - it tells you about coding problems, it offers hints and built in help and it is generally much more upto date with modern JS. It has a whole bunch of handy snippets (e.g. start typing `global` or `clone` or `status` then hit the `tab` key to see how it both helps you AND gets it right every time).

If you really want to revert, search for the word `monaco` in your settings.js file and change it to `ace`, restart, refresh. NOTE: the ace editor will quite probably be removed altogether after NR v4 so (IMHO) I recommend you get used to it and improve your code.

PS: Monaco is the same editor used in the insanely popular code editor "VS Code" - it is good - I would recommend sticking it out.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [16 September 2022 13:01 UTC](https://discourse.nodered.org/t/node-red-3-complains-about-me/67804/5 "2022-09-16T13:01:50Z")

</div>

And perhaps you should rename this thread to "Node-RED V3 function node tells me about poor coding - how do i switch it off" 😛

(joking)

* * *

NOTE: Just because the editor complains, does not mean you have to switch back to the depreciated ACE editor.

If you click the light bulb, you can turn off error checking for that node - but keep all the nice tooltips and auto complete and snippets and built in help!

---

<div class="post-metadata">

**Author:** ![Becker](https://avatars.discourse-cdn.com/v4/letter/b/c77e96/32.png) [@Becker](https://discourse.nodered.org/u/Becker)\
**Post date:** [16 September 2022 13:07 UTC](https://discourse.nodered.org/t/node-red-3-complains-about-me/67804/6 "2022-09-16T13:07:15Z")

</div>

All good 🙃  
i need a strict teacher 😂  
 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/6/66fbf55fd021f76133adb90fe499701fd5912c63.png)  
In this code I need "let" or ?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [16 September 2022 13:09 UTC](https://discourse.nodered.org/t/node-red-3-complains-about-me/67804/7 "2022-09-16T13:09:32Z")

</div>

The best way to evaluate this is...

1. Use `const` always
2. If something complains, change it to `let`

Another way to look at it is...

If you declare something like `const myVar = 1` then later want to change it `myVar = 2` then it should be a `let`

i.e. if there is a separate line of code with an `=` on the right, (e.g. `myVar = somethingElse`) - then use `let`.

PS - monaco editor usually tells you if you get it wrong 👍

---

<div class="post-metadata">

**Author:** ![Becker](https://avatars.discourse-cdn.com/v4/letter/b/c77e96/32.png) [@Becker](https://discourse.nodered.org/u/Becker)\
**Post date:** [16 September 2022 13:13 UTC](https://discourse.nodered.org/t/node-red-3-complains-about-me/67804/8 "2022-09-16T13:13:13Z")

</div>

🧐

1: let Strom = ...  
4: Strom = parseFloat

would this work with  
1: const Strom = ...  
4: Strom = parseFloat

in line 4 I´m changing or do I not ?

* * *

what about functions with more than 1 output:  
var msg1 = {};  
var msg2 = {};

let ? const ?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [16 September 2022 13:15 UTC](https://discourse.nodered.org/t/node-red-3-complains-about-me/67804/9 "2022-09-16T13:15:21Z")

</div>

> [@Becker](#):
>
> 1: let Strom = ...  
> 4: Strom = parseFloat

Yes

> [@Becker](#):
>
> would this work with  
> 1: const Strom = ...  
> 4: Strom = parseFloat

No

> [@Becker](#):
>
> what about functions with more than 1 output:  
> var msg1 = {};  
> var msg2 = {};
> 
> let ? const ?

`const` - UNLESS you later on do `msg1 = {somethingElse}` or `msg1 = "hello"`

This would be flagged by monaco and tell you you cannot reassign a const variable

* * *

Try to remember what I said in prev post.

---

<div class="post-metadata">

**Author:** ![Becker](https://avatars.discourse-cdn.com/v4/letter/b/c77e96/32.png) [@Becker](https://discourse.nodered.org/u/Becker)\
**Post date:** [16 September 2022 13:20 UTC](https://discourse.nodered.org/t/node-red-3-complains-about-me/67804/10 "2022-09-16T13:20:00Z")

</div>

> [@Steve-Mcl](#):
>
> No

it tried with const and it works - I don´t unterstand this...

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [16 September 2022 13:33 UTC](https://discourse.nodered.org/t/node-red-3-complains-about-me/67804/11 "2022-09-16T13:33:14Z")

</div>

Can you show us the function that should fall please. Screenshot.  
Does it fail when it runs?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [16 September 2022 13:34 UTC](https://discourse.nodered.org/t/node-red-3-complains-about-me/67804/12 "2022-09-16T13:34:20Z")

</div>

You have to show me exactly what you wrote for me to be able to understand properly.

Basic rules as I said are const if you never change it let if you do.

The only exception to this is you can create a const object but still change its properties. That is what you are doing.

---

<div class="post-metadata">

**Author:** ![Becker](https://avatars.discourse-cdn.com/v4/letter/b/c77e96/32.png) [@Becker](https://discourse.nodered.org/u/Becker)\
**Post date:** [16 September 2022 13:40 UTC](https://discourse.nodered.org/t/node-red-3-complains-about-me/67804/13 "2022-09-16T13:40:41Z")

</div>

I think I got it now, I was a little bit confused, sorry.  
the monaco editor helps me very well.

---

<div class="post-metadata">

**Author:** ![Becker](https://avatars.discourse-cdn.com/v4/letter/b/c77e96/32.png) [@Becker](https://discourse.nodered.org/u/Becker)\
**Post date:** [16 September 2022 19:02 UTC](https://discourse.nodered.org/t/node-red-3-complains-about-me/67804/14 "2022-09-16T19:02:35Z")

</div>

what happens if I don't prescribe var,let,const ?  
what does the compiler do with it ?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [17 September 2022 07:34 UTC](https://discourse.nodered.org/t/node-red-3-complains-about-me/67804/15 "2022-09-17T07:34:09Z")

</div>

It defaults to `var`, I believe, in order to be able to correctly run legacy code.

---

<div class="post-metadata">

**Author:** ![Becker](https://avatars.discourse-cdn.com/v4/letter/b/c77e96/32.png) [@Becker](https://discourse.nodered.org/u/Becker)\
**Post date:** [17 September 2022 08:30 UTC](https://discourse.nodered.org/t/node-red-3-complains-about-me/67804/16 "2022-09-17T08:30:10Z")

</div>

thx, what about Ä Ö Ü ?  
 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/a/ea979f86ddf10f8514f87a4df373847a06f2cd1b.png)  
the editor is marking it with red -\> not allowed?

And why are some variables turquoise and other black ?  
--\> got it, capital letter turquoise

---

<div class="post-metadata">

**Author:** ![Fabios](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fabios/32/65315_2.png) [@Fabios](https://discourse.nodered.org/u/Fabios)\
**Post date:** [17 September 2022 13:05 UTC](https://discourse.nodered.org/t/node-red-3-complains-about-me/67804/17 "2022-09-17T13:05:53Z")

</div>

Although it's possible to use Unicode Character in variables names, I don't recommend it. My first language is Portuguese, which has a lot of accented characters, and I don't use them in variables. Many chances of technical problems, besides the typos; If it's already difficult without accents, imagine with them. And the colors are another help from Monaco editor, depends on the theme you are using. But in this case, the editor is not recognizing the Übers as a variable, that's why it's got a different color. Try to rename to Ubers and see the change. About themes : [https://discourse.nodered.org/t/how-to-use-themes-with-monaco-editor/48310](https://discourse.nodered.org/t/how-to-use-themes-with-monaco-editor/48310)

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [17 September 2022 13:20 UTC](https://discourse.nodered.org/t/node-red-3-complains-about-me/67804/18 "2022-09-17T13:20:32Z")

</div>

> [@Becker](#):
>
> what happens if I don't prescribe var,let,const ?  
> what does the compiler do with it ?

I believe that what happens is that the JIT assigns the variable to the current global scope. This may have unexpected side effects.

If you use `var`, the variable is "hoisted" to the top of your top-level current code scope which again can have confusing side effects. Though very occasionally, this can be used to simplify your code - use with caution though.

`let` and `const` are never hoisted and are defined at the current local scope. So if you define something within `{ .... }` brackets using let or const, it is defined only for that scope and is not available outside it. This is also good for memory efficiency as it allows the garbage collector routine to recover memory more quickly.

Sidebar: Little known but occasionally useful, in JavaScript you can use `{ ... }` on their own (not just with a function, if/then, etc) to create a new scope. A bit like creating a function and immediately calling it but without the function overheads. Variables are inherited downwards of course so you don't need function arguments in this case.

---

<div class="post-metadata">

**Author:** ![Fabios](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fabios/32/65315_2.png) [@Fabios](https://discourse.nodered.org/u/Fabios)\
**Post date:** [17 September 2022 13:37 UTC](https://discourse.nodered.org/t/node-red-3-complains-about-me/67804/19 "2022-09-17T13:37:17Z")

</div>

A good explanation [here](https://www.freecodecamp.org/news/var-let-and-const-whats-the-difference/)...

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [1 October 2022 13:37 UTC](https://discourse.nodered.org/t/node-red-3-complains-about-me/67804/20 "2022-10-01T13:37:43Z")

</div>

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