debug nodejs with nodemon and intellij

Noticed that if I run nodemon within intellij, I would not be able to debug any more inside intellij.
Not sure what reason it is. If just run the nodejs, no problem. However once I add the ‘/usr/local/bin/nodemon’ into the Node parameters of the run config, the breakpoint would not work.

solution

To solve this problem, i have to use the Node.js remote debug.
Steps are

1. add a debug port to the Node parameters

–debug=3001. Note It is double dash. this should be the same as the port in the following remote debug config.

in the intellij doc, another option is to use –debug-brk which would enable the debug to run from the start. I tried this param, it works if I just change some front end html/js, however it would not work when backend js changed. Might have other workaround if you have to debug some init processes.

debug config intellij nodejs

debug config intellij nodejs

2. add a new Node.js remote debug config in Intellij

remote debug intellij node

remote debug intellij node

Now you should be able to use run RUN to start the server.js application and use DEBUG to start the ‘remote server debug’ and then set break point in your node app. 🙂

Advertisements

4 comments

  1. ilaif · June 17, 2015

    Thank you! It’s awesome and it works.

  2. Arnab Bhattacharya · May 5

    hi, i followed the steps above and when i launch the debugger, in the console pane it shows “connected to localhost:3001”, however the application doesnt stop at break points. im on intellij idea 14. would appreciate any help.

    • LeOn · May 6

      hmmm, i do not see anything special in these setup steps. I do not have much clue on what’s going on in ur machine.
      U sure u r using the remote debug rather than just start the server in debug mode?

      • Arnab Bhattacharya · May 9

        yes, i m running the server on port 9000 and specifying port 3001 for debug. Then I’m starting the remote debugger from intellij and it shows connected to 3001. Post this, the code doesnt break at the specified breakpoints. However If i press the pause button (Suspend program execution and enable debugging)… the program pauses, but no idea where and then if i click the step to next line it completes the execution and doesnt break anywhere.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s