# How to debug an own node with the node.js debugger?

**URL:** https://discourse.nodered.org/t/how-to-debug-an-own-node-with-the-node-js-debugger/5737
**Category:** Developing Nodes
**Created:** [12 December 2018 23:12 UTC](https://discourse.nodered.org/t/how-to-debug-an-own-node-with-the-node-js-debugger/5737 "2018-12-12T23:12:11Z")
**Posts on this page:** 1
**Showing post:** 4

<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: [13 December 2018 12:39 UTC](https://discourse.nodered.org/t/how-to-debug-an-own-node-with-the-node-js-debugger/5737/4 "2018-12-13T12:39:31Z")

</div>

Hey @noir

You will need to use both command arguments to let Node-RED halt at the first line **AND** make sure that from then on your debugger can communicate with NodeJs:

```auto
node --inspect --debug-brk /usr/lib/node_modules/node-red/red.js

```

Will add some extra explanation below, for those who want to debug their code using Chrome...

Some remarks:

- Note that you **cannot** debug code in function nodes! The code in a function node is one single piece of text, that is handed over to NodeJs to execute as one whole. I wrote some extra [explanation](https://groups.google.com/d/msg/node-red/LxgNFTGMjiE/hrlpbzBzEgAJ) in the past about it ...
- Probably Visual Studio Code is much more powerful, but I debug using Chrome because it is simple and offers everything I need ...
- When you search on the web, you will also come across a **node-inspector** module. In the beginning NodeJs had a dedicated debug protocol, so you needed that _browser plugin_ to connect your browser debugger to NodeJs. However now NodeJs supports a standard debug protocol, so browser like Chrome can directly communicate with NodeJs without plugins. So we won't use that technology in this discussion ...

I use Chrome both to debug:

- The **client-side** of my node (which runs in my browser like the Dashboard or the Flow editor), i.e. the Javascript used for my node's config screen. For example stuff from the `oneditprepare` function.
- The **server-side** of my node (which runs in my flow on my Raspberry), i.e. the code that is e.g. triggered when a new input message arrives.

As mentioned before the technology (to debug server-side NodeJs from Chrome) is **experimental** , so it changes from time to time how it has to be used:

- In **older NodeJs versions** you had to startup Node-RED (on a Raspberry for example) like this:

- Starting from starting from **NodeJs version 7.5.0** , you need to specify **extra** in your command which remote ip address is allowed to debug (see this security [issue](https://github.com/nodejs/node/issues/11591) in NodeJs)):

- Starting **from NodeJs version 8.?** , the command displays a `ws://...` address instead of `chrome-devtools://...` address. To open such an URL with Chrome you have to follow these steps:

I'm only using the latest mechanism, so I cannot test the others anymore for you (in case of troubles)!

Bart

---

_[View the full topic](https://discourse.nodered.org/t/how-to-debug-an-own-node-with-the-node-js-debugger/5737)._
