# How to debug a function Node?

**URL:** <https://discourse.nodered.org/t/how-to-debug-a-function-node/38024>\
**Category:** Feature Requests\
**Created:** [26 December 2020 08:40 UTC](https://discourse.nodered.org/t/how-to-debug-a-function-node/38024 "2020-12-26T08:40:50Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [26 December 2020 08:51 UTC](https://discourse.nodered.org/t/how-to-debug-a-function-node/38024/2 "2020-12-26T08:51:03Z")

</div>

> [@PizzaProgram](#):
>
> Forum search failures

If you really want to debug - use a debugger 🙂

Lots of clues on the forum

> [@How to proper debug custom node](https://discourse.nodered.org/t/how-to-proper-debug-custom-node/9308/13):
>
> This is how I debug a custom node in VS Code... It works for me however since this is a dist version of node-red its difficult sometimes to debug client side issues. Other than that, debug stop points work in my node js files. For debuging my .html files, i enter debugger into the function & open F12 (chrome debugger stops on the debugger statement) Setup... Install node-red as per instructions on [nodered.org](http://nodered.org) Run it one time so that .node-red folder is generated Install own node... cd c:…

> [@Debug JS code inside function node](https://discourse.nodered.org/t/debug-js-code-inside-function-node/26925/5):
>
> Here is it... And although the topic is about debuging a custom node - it works perfectly well for your requirement... Just put debugger in your function node e.g... var x = msg.payload; debugger //...some complex code //...some complex code //...some complex code //...some complex code return msg; and if its all working, VSCode will pause on the debugger line.

> [@Dumb question about editing a node](https://discourse.nodered.org/t/dumb-question-about-editing-a-node/34434/63):
>
> add debugger key word into your node, restart node-red, open the browser & devtools, give it a go. Y As i said earlier, I've not used it but i suspect it will fire when deleted from the editor (before deploy - so in other words, still active in the runtime). If you want to remove callbacks at the server side, I would suggest you need to use this.on('close' and its parameters to determine if there is a clean up (at server side) to do. [reference](https://nodered.org/docs/creating-nodes/node-js#closing-the-node)

* * *

### demo of debugging a function node...

While running with vscode debugger attached, use the keyword `debugger` to instruct the debugger to stop...

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

Real debugging...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/9/193b15c037848e6c3974047ebf774fc5800b62a0.png)

---

_[View the full topic](https://discourse.nodered.org/t/how-to-debug-a-function-node/38024)._
