Search code examples
node.jsexpressdebuggingwebstormpm2

How to configure WebStorm debugger to work with my Express app


I'm trying to debug a Node Express application with the WebStorm debugger

The thing is that the WebStorm debugger doesn't hit the breakpoint although I think it set up correctly.

I run my application by:

node --inspect server.js

and then the server is up, accepting requests, it logged:

Debugger listening on ws://127.0.0.1:9229/5790aa86-c46c-48bc-998c-e014244440b7

(I've also tried: "node --inspect=127.0.0.1:9229" server.js which didn't worked)

My WebStorm debugger config is:

Node.js Remote Debug
Host: 127.0.0.1
Port: 9229

Node version is: v8.11.4

WebStorm version: WebStorm 2016.3.4


Eventually I want to run it with pm2, so an answer which will guide me how to set the process.yml would be great. I've tried to put in the node_args ['--inspect'] but the same results, it did not worked.


Solution

  • Node.js Remote run configuration can only be used when debugging with TCP-based Protocol (Node.js < 7.x).

    To remotely debug application with Chrome Debugging Protocol (with --inspect/--inspect-brk), you need using Chromium Remote run configuration

    • run your app with node --inspect-brk=<my custom port here> index.js

    • create a Chromium Remote run configuration, specify your custom port as a Port: there, press Debug

    Note: these instructions refer to WebStorm < 2018.x. With recent WebStorm releases, you need using Attach to Node.js/Chrome configuration for attaching to a running process