# How to proper debug custom node

**URL:** <https://discourse.nodered.org/t/how-to-proper-debug-custom-node/9308>\
**Category:** General\
**Created:** [22 March 2019 10:07 UTC](https://discourse.nodered.org/t/how-to-proper-debug-custom-node/9308 "2019-03-22T10:07:52Z")\
**Posts on this page:** 1\
**Showing post:** 13

<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:** [10 May 2019 14:13 UTC](https://discourse.nodered.org/t/how-to-proper-debug-custom-node/9308/13 "2019-05-10T14:13:00Z")

</div>

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...

1. Install node-red as per instructions on [nodered.org](http://nodered.org)
2. Run it one time so that `.node-red` folder is generated
3. Install own node...
  1. `cd c:\users\me\.node-red` _(or linux equivelant)_
  2. `npm install c:\path_to_my_node`

4. Open VS code & "open folder" created on step 2 e.g. `c:\users\me\.node-red` _(or linux equivelant)_
5. Add following configuration to vscode `launch.json` (press CTRL+SHIFT+P then type launch.json)...

```auto
{
  "version": "0.2.0",
  "configurations": [
   
    {
      "type": "node",
      "request": "launch",
      "name": "Launch Node-red",
      "program": "c:\\path_to_npm_global\\node-red\\red.js",
      "runtimeArgs": ["--preserve-symlinks", "--experimental-modules"],
      "env": {
        "NO_UPDATE_NOTIFIER": "1"
      }
    },
    {
      "type": "node",
      "request": "launch",
      "name": "Debug Current File",
      "program": "${file}"
    },
    { "type": "node", "request": "attach", "name": "Attach to Process", "processId": "${command:PickProcess}" } 
    
  ]
}

```

1. Select "Launch Node-red" from the debug drop down & press `F5`

Hope this helps

Edit...  
Some notes on my vs code setup

- `"NO_UPDATE_NOTIFIER": "1"` Without this, node-red takes over 3 minute startup (corporate proxy issue)
- `--preserve-symlinks` because `npm install c:\folder\my_node` creates a symlink & debug points wont stop on your .js code without it

---

_[View the full topic](https://discourse.nodered.org/t/how-to-proper-debug-custom-node/9308)._
