# Node Red parser not flagging syntax error?

**URL:** <https://discourse.nodered.org/t/node-red-parser-not-flagging-syntax-error/64217>\
**Category:** General\
**Created:** [21 June 2022 20:18 UTC](https://discourse.nodered.org/t/node-red-parser-not-flagging-syntax-error/64217 "2022-06-21T20:18:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nodi.Rubrum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodi.rubrum/32/107482_2.png) [@Nodi.Rubrum](https://discourse.nodered.org/u/Nodi.Rubrum)\
**Post date:** [21 June 2022 20:18 UTC](https://discourse.nodered.org/t/node-red-parser-not-flagging-syntax-error/64217/1 "2022-06-21T20:18:48Z")

</div>

Node Red parser not flagging syntax error?

I was trying to find a flow logic error and wasted about 2 hours double checking everything. Only to find that it appears the javascript parser missed a typo? Do you see it? Hint DEVICE const.

```auto
const DEVICE='Device,'
      MONITOR='Monitor',
      STATUS='Status',
      ABORT='Abort',
      LOGOUT='Logout';

```

The above is not correct, but NR parser did not flag it? Now I suspect this is actually a node parser error, because NR is just using node to validate function nodes?

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [21 June 2022 20:26 UTC](https://discourse.nodered.org/t/node-red-parser-not-flagging-syntax-error/64217/2 "2022-06-21T20:26:32Z")

</div>

Are you using the (default) `ACE` editor, or have you enabled the `monaco` editor?

What you have shared there is actually valid JavaScript (albeit not 'good' JavaScript). If you open your browser's JavaScript console and paste that in and run it, you won't get an error.

That said, it isn't _good_ JavaScript because you are setting `MONITOR` etc without having declared them as `var`/`let`/`const` etc. However, the built-in JavaScript parser used by ACE doesn't flag this.

The `monaco` editor widget has much better defaults for highlighting this type of thing:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/a/8aab4db53ae871832026e355e8abd564b5b59b4d.png)

We are making monaco the default editor in Node-RED 3.0.

---

<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:** [21 June 2022 20:44 UTC](https://discourse.nodered.org/t/node-red-parser-not-flagging-syntax-error/64217/3 "2022-06-21T20:44:04Z")

</div>

> [@Nodi.Rubrum](#):
>
> `const DEVICE='Device,'`

I think you have the comma in the wrong place. And as nick has pointed out, Monaco recognises this kinda thing.

---

<div class="post-metadata">

**Author:** ![Nodi.Rubrum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodi.rubrum/32/107482_2.png) [@Nodi.Rubrum](https://discourse.nodered.org/u/Nodi.Rubrum)\
**Post date:** [22 June 2022 06:50 UTC](https://discourse.nodered.org/t/node-red-parser-not-flagging-syntax-error/64217/4 "2022-06-22T06:50:58Z")

</div>

Right, to me this is just a typical typo, comma in the wrong place, was surprised it was not flagged.

No, I have not customized the editor at all.

Yeah, I figured this was not NR per se! Just found it odd.

Oh, so 'good' JavaScript wants explicit declaration per variable/constant? Interesting, my experience with C, C#, VB, [VB.NET](http://VB.NET), python, etc. complex or combined declarations is typical, because JavaScript never flagged it, I never really considered it an issue, live and learn. 🙂

Looking forward to 3.0, I just seem to have all the fun. LOL.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [22 June 2022 06:59 UTC](https://discourse.nodered.org/t/node-red-parser-not-flagging-syntax-error/64217/5 "2022-06-22T06:59:24Z")

</div>

> [@Nodi.Rubrum](#):
>
> Oh, so 'good' JavaScript wants explicit declaration per variable/constant?

No, you can combine them in a single statement:

```auto
const a = 1, b = 2

```

The problem with your code, as you know, is the missing comma at the end of the first line.

The makes the interpreter see `MONITOR` as the start of a new statement, rather than a continuation.

---

<div class="post-metadata">

**Author:** ![Nodi.Rubrum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodi.rubrum/32/107482_2.png) [@Nodi.Rubrum](https://discourse.nodered.org/u/Nodi.Rubrum)\
**Post date:** [22 June 2022 17:31 UTC](https://discourse.nodered.org/t/node-red-parser-not-flagging-syntax-error/64217/6 "2022-06-22T17:31:17Z")

</div>

Ah... man reminds me of my 'compiler theory' class at University, where there were just 'wonderful' code parsing complexities. Never look at a parser... the code is always ugly... I remember my professor stated.

---

<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:** [21 August 2022 17:32 UTC](https://discourse.nodered.org/t/node-red-parser-not-flagging-syntax-error/64217/7 "2022-08-21T17:32:08Z")

</div>

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