# "flow" variable predefined?

**URL:** <https://discourse.nodered.org/t/flow-variable-predefined/100927>\
**Category:** General\
**Created:** [6 May 2026 23:14 UTC](https://discourse.nodered.org/t/flow-variable-predefined/100927 "2026-05-06T23:14:53Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![knowledgeshark](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knowledgeshark/32/4820_2.png) [@knowledgeshark](https://discourse.nodered.org/u/knowledgeshark)\
**Post date:** [6 May 2026 23:14 UTC](https://discourse.nodered.org/t/flow-variable-predefined/100927/1 "2026-05-06T23:14:53Z")

</div>

I have an obscure question: I just upgraded to the newest node-red, and one of my javascript nodes has a compile error where it says in my own code that "var **flow**" is already defined.

Has something changed such that "flow" is a reserved function/method?

It says:

> Duplicate identifier 'flow'.(2300)  
> var flow: any

thanks

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [7 May 2026 05:01 UTC](https://discourse.nodered.org/t/flow-variable-predefined/100927/2 "2026-05-07T05:01:34Z")

</div>

In Node-RED, the `flow` context variable is used to access variables that are scoped to the current flow. You do not use `flow.path`, instead, you use `flow.get('variableName')` to retrieve a value and `flow.set('variableName', value)` to store it.

> **[Working with context : Node-RED](https://nodered.org/docs/user-guide/context)**

As you have probably updated from a version of node-red that used Ace as the editor to Monaco, Node-red now has better error reporting.

Quick fix remove var.  
Best fix use get() and set() , and do not use flow, global and context as variable names.

---

<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:** [7 May 2026 10:40 UTC](https://discourse.nodered.org/t/flow-variable-predefined/100927/3 "2026-05-07T10:40:00Z")

</div>

> [@knowledgeshark](#):
>
> var **flow**

`flow` is an internal variable and should not be re-used. I think the reason you are now getting an error is that the function node's code checking is improved with the use of the Monaco editor.

You \_could do something like this:

```javascript
{ // Creates a new localised context
   // const/let restricts this to the localised context
   const flow = {} // or whatever
   ...
}

```

But better to avoid pre-defined variable/constant names. Also best to use const or let rather than var which can cause hard-to-find bugs.

When using Monaco editor, you can right-click on the variable name and rename it, it will be changed throughout your code for you.

---

<div class="post-metadata">

**Author:** ![knowledgeshark](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knowledgeshark/32/4820_2.png) [@knowledgeshark](https://discourse.nodered.org/u/knowledgeshark)\
**Post date:** [7 May 2026 15:16 UTC](https://discourse.nodered.org/t/flow-variable-predefined/100927/4 "2026-05-07T15:16:28Z")

</div>

Well I'm glad that's resolved. I've been using "flow" as a variable for a number of years, so will fix that.

Hopefully the design team debated not using common names (like global or flow) instead of special names like \_global or global$ or something.

Thanks.

---

<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:** [7 May 2026 15:23 UTC](https://discourse.nodered.org/t/flow-variable-predefined/100927/5 "2026-05-07T15:23:18Z")

</div>

😃

> [@knowledgeshark](#):
>
> Hopefully the design team debated not using common names (like global or flow) instead of special names like \_global or global$ or something.

To be fair, I think you may be the _only_ person to have ever hit the issue! 😉

Also to be fair, the switch from the ACE editor to Monaco really helps with things like this as it spots a lot more seemingly innocuous errors.

As function nodes run in their own node.js VM wrapper, some things such as Node.js's globals are not available. So using `global` for global context variables isn't so much of an issue.

---

<div class="post-metadata">

**Author:** ![knowledgeshark](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knowledgeshark/32/4820_2.png) [@knowledgeshark](https://discourse.nodered.org/u/knowledgeshark)\
**Post date:** [7 May 2026 15:30 UTC](https://discourse.nodered.org/t/flow-variable-predefined/100927/6 "2026-05-07T15:30:13Z")

</div>

I like to be a trend setter:-) My JSON has a bunch of flows so the singleton is flow.

Thanks,

---

<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 May 2026 15:31 UTC](https://discourse.nodered.org/t/flow-variable-predefined/100927/7 "2026-05-21T15:31:02Z")

</div>

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