How to proper debug custom node

Hi Steve,
Thanks for the quick response.
I tried on the sample "lower-case" node and it is working on the "lower-case.js" file. But.. how do I debug the .html file AngularJS code? and in case if I am calling Angular code written in another .js file (sitting in the same directory), how do I debug that? browser debugger is not helping much.
Please help

The html is client side so you can't debug in the same way.

Add the keyword debugger in your code where you want to stop & open chrome Devtools (F12)

1 Like

Thank you. It is working.

Thanks for the excellent guide!

I've got to the point where my breakpoints work.
However, my node's JS code relies on external programs which I locate using relative paths, relative to the actual root folder of the node implementation. This is where the VSCode debugger falls apart:

  1. AFAIK, the custom nodes are installed as symlinks into ~/.node-red
  2. My node's JS code uses _dirname as the anchor folder to find external resources.
  3. Looks like VSCode debugger interprets the symlinked folder as a physical folder under ~/.node-red, which breaks all my relative paths.

The code runs find in the real node-red environment.
Is there any best practice to make VSCode debugger work with the symlink'ed node without breaking the production code that works fine with the existing relative paths?

Alright, solved it myself. All I need is to use fs.realpath() around my _dirname usage.

1 Like