WebStorm makes it easier to debug Node.js apps. You can put breakpoints right in your source code (no more
You can do many things that will help you explore the code and understand where the bug is. In the debugging tool window, you can see the call stack and the variables in their current state, evaluate expressions in the editor, and step through the code. And you can start debugging your app very quickly. Here’s how.
We’ll use a simple Express app as an example.
We need to do two things: first create a new Node.js run/debug configuration that will start the app, and then put a breakpoint.
- To create a configuration, go to the Run menu and select Edit configurations… Click the + icon and select Node.js configuration type.
- Now specify the path to the main file of the application that starts it. For the Express app it’s bin/www
- Save the configuration. Put the breakpoints in your code. Now press Ctrl-D on macOS or Shift+F9 on Windows & Linux to debug the app (or click the green bug-like icon).
Now if you do the actions that trigger the code where the breakpoint is, the app will pause on the breakpoint. Explore the call stack and the variables in the debugging tool window, hover over the expressions in the editor to see their current state, step through the code, or put new breakpoints to help you debug further. Continue reading