# Debug JS code inside function node

**URL:** https://discourse.nodered.org/t/debug-js-code-inside-function-node/26925
**Category:** FAQs
**Created:** [19 May 2020 13:20 UTC](https://discourse.nodered.org/t/debug-js-code-inside-function-node/26925 "2020-05-19T13:20:02Z")
**Posts on this page:** 1
**Showing post:** 14

<div class="post-metadata">

### Author: ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)
#### Post date: [19 May 2020 21:21 UTC](https://discourse.nodered.org/t/debug-js-code-inside-function-node/26925/14 "2020-05-19T21:21:40Z")

</div>

Hey Steve,  
Thanks a lot for the tip 👍 👍 👍 👍

At the time being this was not possible. But seems that since NodeJs version _ **8.4.0** _ it is indeed possible to attach a remote debugger to a vm context. What a pity that I haven't tried it anymore meanwhile...

Here are the steps to _ **debug a function node via the Chrome debugger** _:

1. You need to configure _ **ONCE** _ the IP address of your Node-RED server, via `chrome://inspect`:

2. Enter a `debugger;` statement in your function node code:

3. Start your Node-RED server in debug-mode (which means it is allowed to attach a debugger process), e.g. on Linux:

4. Node-RED will start now, and NodeJs allows a debugger process to attach:

5. Now Chrome should see that the debugger can be attached:

6. _ **After** _ clicking the "_inspect_" link, a Chrome developer console window will open. You will arrive in the debugger at your function node:

7. Now you can step through your code (via the navigation buttons on the top right), show content of variables (on the lower right), and so on...

8. Click on a line number to add a breakpoint, where your debugger needs to stop:

Although Visual Studio code offers much more functionality, for lots of users it might be easier to start with the Chrome debugger I think ...

Have fun with debugging your function node!  
Bart

---

_[View the full topic](https://discourse.nodered.org/t/debug-js-code-inside-function-node/26925)._
