# Cannot find name 'flow' (error 2304) and red squiggle under \`msg\`

**URL:** https://discourse.nodered.org/t/cannot-find-name-flow-error-2304-and-red-squiggle-under-msg/96796
**Category:** General
**Tags:** monaco, function-node
**Created:** [29 April 2025 09:11 UTC](https://discourse.nodered.org/t/cannot-find-name-flow-error-2304-and-red-squiggle-under-msg/96796 "2025-04-29T09:11:23Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![xpxiong](https://avatars.discourse-cdn.com/v4/letter/x/258eb7/32.png) [@xpxiong](https://discourse.nodered.org/u/xpxiong)
#### Post date: [29 April 2025 09:11 UTC](https://discourse.nodered.org/t/cannot-find-name-flow-error-2304-and-red-squiggle-under-msg/96796/1 "2025-04-29T09:11:23Z")

</div>

When I write 'let data = flow.get("data")' in the function node, an error will be reported

 ![20250429-164237](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/7/47344756a73d47e03c4b3647ff2a75c93b0d52c1.jpeg)

---

<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: [29 April 2025 10:24 UTC](https://discourse.nodered.org/t/cannot-find-name-flow-error-2304-and-red-squiggle-under-msg/96796/2 "2025-04-29T10:24:26Z")

</div>

Where are you seeing that error? Can you post a screenshot please?

Also, which version of node-red are you using?

---

<div class="post-metadata">

### Author: ![xpxiong](https://avatars.discourse-cdn.com/v4/letter/x/258eb7/32.png) [@xpxiong](https://discourse.nodered.org/u/xpxiong)
#### Post date: [29 April 2025 15:17 UTC](https://discourse.nodered.org/t/cannot-find-name-flow-error-2304-and-red-squiggle-under-msg/96796/3 "2025-04-29T15:17:16Z")

</div>

Node-RED version: v4.0.9  
Node.js version: v22.14.0  
Thank you!

---

<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: [29 April 2025 15:58 UTC](https://discourse.nodered.org/t/cannot-find-name-flow-error-2304-and-red-squiggle-under-msg/96796/4 "2025-04-29T15:58:24Z")

</div>

Please select the three nodes with the red triangles and Export them to the clipboard (CTRL+E or Export in the menu) and paste it here. When pasting, in order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote `````)

````auto
``` 
   code goes here 
```

````

See this post for more details - [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

---

<div class="post-metadata">

### Author: ![xpxiong](https://avatars.discourse-cdn.com/v4/letter/x/258eb7/32.png) [@xpxiong](https://discourse.nodered.org/u/xpxiong)
#### Post date: [29 April 2025 16:08 UTC](https://discourse.nodered.org/t/cannot-find-name-flow-error-2304-and-red-squiggle-under-msg/96796/5 "2025-04-29T16:08:54Z")

</div>

```auto
let data = msg.payload;
data = JSON.parse(data);
msg.payload = data;
return msg;

```

---

<div class="post-metadata">

### Author: ![xpxiong](https://avatars.discourse-cdn.com/v4/letter/x/258eb7/32.png) [@xpxiong](https://discourse.nodered.org/u/xpxiong)
#### Post date: [29 April 2025 16:10 UTC](https://discourse.nodered.org/t/cannot-find-name-flow-error-2304-and-red-squiggle-under-msg/96796/6 "2025-04-29T16:10:26Z")

</div>

I don't think it's a problem with the code. The same code runs normally on another computer. Could it be related to the version of nodejs or that some packages of Node-Red did not load properly?

---

<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: [29 April 2025 16:29 UTC](https://discourse.nodered.org/t/cannot-find-name-flow-error-2304-and-red-squiggle-under-msg/96796/7 "2025-04-29T16:29:37Z")

</div>

Can you try it in a different browser?  
If it is the same in another browser then check the browser developer console for errors.

---

<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: [29 April 2025 17:05 UTC](https://discourse.nodered.org/t/cannot-find-name-flow-error-2304-and-red-squiggle-under-msg/96796/8 "2025-04-29T17:05:00Z")

</div>

We have seen this type of error before - where the editor doesn't recognise the built-in variables we define. My search skills are failing to find the previous threads on it.. but @Steve-Mcl may have better recall than I do on it.

---

<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: [29 April 2025 17:16 UTC](https://discourse.nodered.org/t/cannot-find-name-flow-error-2304-and-red-squiggle-under-msg/96796/9 "2025-04-29T17:16:53Z")

</div>

I am struggling to think of the search terms necessary to find a previous posting 🤔

@xpxiong can you check the browsers console (devtools F12)

Also, what browser is this and what version?

Lastly, can you check your node-red logs - is node-red crashing / restarting without you realising?

---

<div class="post-metadata">

### Author: ![xpxiong](https://avatars.discourse-cdn.com/v4/letter/x/258eb7/32.png) [@xpxiong](https://discourse.nodered.org/u/xpxiong)
#### Post date: [30 April 2025 02:20 UTC](https://discourse.nodered.org/t/cannot-find-name-flow-error-2304-and-red-squiggle-under-msg/96796/10 "2025-04-30T02:20:06Z")

</div>

My browser version is 135.0.7049.115 (official version) (64-bit). I think it's a problem with the back-end program because when I disconnect from the server and then edit the code of the function node, it won't report an error。Besides, I won't view the required information in the console.

 ![Snipaste_2025-04-30_10-16-35](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/f/6f0b8858d4354dcc2d9bf8ee60a44266c391cac8.png)

---

<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: [30 April 2025 05:17 UTC](https://discourse.nodered.org/t/cannot-find-name-flow-error-2304-and-red-squiggle-under-msg/96796/11 "2025-04-30T05:17:59Z")

</div>

I remember now.

There was a similar incident discussed on a node-red slack channel. The user was not getting types delivered.

Unfortunately I forget the reason.

It was either...

- Due to proxy or firewall blocking
- Browser plugin
- Type files missing on their node-red installation

Please do the following (Keep Dev tools open)...

1. Select the network tab in dev tools.
2. Refresh the page
3. Open a function node
4. Check for non 200 response codes

Edit: here is a screenshot the slack thread

 ![Screenshot_20250430-062231](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/7/e7549e3568d27338aca3229689ad1a0fe7a94a5d.jpeg)

---

<div class="post-metadata">

### Author: ![xpxiong](https://avatars.discourse-cdn.com/v4/letter/x/258eb7/32.png) [@xpxiong](https://discourse.nodered.org/u/xpxiong)
#### Post date: [30 April 2025 07:46 UTC](https://discourse.nodered.org/t/cannot-find-name-flow-error-2304-and-red-squiggle-under-msg/96796/12 "2025-04-30T07:46:39Z")

</div>

It is indeed very likely that there are some limitations in the company network, but there are no issues regarding server errors in my console. thank you

 ![333](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/9/69742c07a95f7e15d5365d5acf10ed5848f073dd.png)

---

<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: [30 April 2025 07:57 UTC](https://discourse.nodered.org/t/cannot-find-name-flow-error-2304-and-red-squiggle-under-msg/96796/13 "2025-04-30T07:57:24Z")

</div>

All your responses are ~275b - that is definitely your issue. I suspect the company or browser policy setting or something is returning _something else_

This is what they should be

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/2/2247aa6cb9facbf494180501080f85dac091df80.png)

If you click one of the ts files, then preview what do you see?

I see this:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/b/0b9f928e4992391588c57be660322d3a069496c7.png)

---

<div class="post-metadata">

### Author: ![xpxiong](https://avatars.discourse-cdn.com/v4/letter/x/258eb7/32.png) [@xpxiong](https://discourse.nodered.org/u/xpxiong)
#### Post date: [30 April 2025 08:33 UTC](https://discourse.nodered.org/t/cannot-find-name-flow-error-2304-and-red-squiggle-under-msg/96796/14 "2025-04-30T08:33:38Z")

</div>

Thank you very much for helping me find the problem. Figure 1 shows the content of the ts file when accessing the server. Figure 2 shows the content of the ts file when the server is accessed. Figure 3 shows accessing the contents of the ts file in the normally running node-red locally. The size of all their ts files is approximately around 275B.  
I'm wondering if it was caused by my setting the node-red password locally and then directly copying the project to the server.

 ![444](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/5/e5ca807d93c7ec47aa9c39ea87c2f00419b10c58.png)  
 ![555](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/3/b3e9cf598b8e4f707cff3ff5b2d1fae8e494e93d.png)  
 ![666](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/d/6d8b0598f25404ed30b70ba2a6b7e17d089f7df7.png)

---

<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: [30 April 2025 08:56 UTC](https://discourse.nodered.org/t/cannot-find-name-flow-error-2304-and-red-squiggle-under-msg/96796/15 "2025-04-30T08:56:33Z")

</div>

> [@xpxiong](#):
>
> I'm wondering if it was caused by my setting the node-red password locally and then directly copying the project to the server.

That should have no bearing.

The issue looks like a network thing.

> [@xpxiong](#):
>
> ![444](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/5/e5ca807d93c7ec47aa9c39ea87c2f00419b10c58.png)

What do you see if you select **preview** for this entry?

* * *

### One more test

- Leave the dev tools open
- disable the cache
  - ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/f/1f638145db1f619cd679294f1cad28aaab90ca79.png)

- refresh the browser

Do you now get `200` status and valid typescript data?

* * *

### Final thoughts

The most probable explanation is that a **network intermediary device** (like a firewall application) in your company's network is intercepting the cache-busted requests for the `*.d.ts` files. This is incorrectly deciding to send a `304 Not Modified` response, preventing your browser/client from downloading the actual ts (typescript) text file.

---

<div class="post-metadata">

### Author: ![xpxiong](https://avatars.discourse-cdn.com/v4/letter/x/258eb7/32.png) [@xpxiong](https://discourse.nodered.org/u/xpxiong)
#### Post date: [30 April 2025 09:40 UTC](https://discourse.nodered.org/t/cannot-find-name-flow-error-2304-and-red-squiggle-under-msg/96796/16 "2025-04-30T09:40:27Z")

</div>

After disabling the cache, the '.d.ts' file can be obtained normally.

 ![7](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/9/09a3f7d9193b288e00baec4e71afd0d9632111c0.png)

But when I opened it, it was garbled. I'm not sure where the problem lies

 ![8](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/3/93f9ccb42dc68ac1122e447724efeef7d6029f84.png)

---

<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: [30 April 2025 10:51 UTC](https://discourse.nodered.org/t/cannot-find-name-flow-error-2304-and-red-squiggle-under-msg/96796/17 "2025-04-30T10:51:47Z")

</div>

Can access this particular node red via a browser using the localhost URL (I.e. actually open its editor on the server itself using a localhost or 127.0.0.1 url) do you get valid Typescript?

If yes, that would confirm your network is intercepting and replacing the response.

If you do have local access AND the data is still not correct, then perhaps the .ts files on your installation are corrupt.

---

<div class="post-metadata">

### Author: ![xpxiong](https://avatars.discourse-cdn.com/v4/letter/x/258eb7/32.png) [@xpxiong](https://discourse.nodered.org/u/xpxiong)
#### Post date: [9 May 2025 05:51 UTC](https://discourse.nodered.org/t/cannot-find-name-flow-error-2304-and-red-squiggle-under-msg/96796/18 "2025-05-09T05:51:16Z")

</div>

It can't be accessed normally on the server either. How should I locate the damaged js file or fix the problem? thank you

---

<div class="post-metadata">

### Author: ![xpxiong](https://avatars.discourse-cdn.com/v4/letter/x/258eb7/32.png) [@xpxiong](https://discourse.nodered.org/u/xpxiong)
#### Post date: [9 May 2025 06:19 UTC](https://discourse.nodered.org/t/cannot-find-name-flow-error-2304-and-red-squiggle-under-msg/96796/19 "2025-05-09T06:19:25Z")

</div>

Thank you very much for your answer. I have now identified the problem. It's because the company's computer has added an encryption policy. I copied the encrypted Node-Red project and the nodejs environment to the server. Previously, I only decrypted the Node-Red project file, which couldn't solve the problem. Now I have decrypted the problems that have been solved in the nodejs environment. Thank you again.谢谢！

---

<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: [23 May 2025 06:19 UTC](https://discourse.nodered.org/t/cannot-find-name-flow-error-2304-and-red-squiggle-under-msg/96796/20 "2025-05-23T06:19:59Z")

</div>

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