dsrest.blogg.se

Webstorm nodejs debug
Webstorm nodejs debug




webstorm nodejs debug
  1. WEBSTORM NODEJS DEBUG HOW TO
  2. WEBSTORM NODEJS DEBUG CODE
  3. WEBSTORM NODEJS DEBUG WINDOWS

Good news: you can still debug this app with WebStorm! In the cases we described above, the application is actually started from WebStorm, but sometimes you may want to attach to a process that is already running (for example, in a Docker container started on your machine).

WEBSTORM NODEJS DEBUG CODE

Once the breakpoint is hit, you can step through the code and do everything you would when debugging a JavaScript app.Īttaching debugger to the running node process

WEBSTORM NODEJS DEBUG WINDOWS

Put the breakpoints and start the debug configuration ( Ctrl-D on macOS or Shift+F9 on Windows & Linux). Specify the path to the compiled JavaScript file that starts the app. Now let’s create a new Node.js debug configuration (select Run – Edit configurations – Add). In our example, we need to run npm run build for that. The right way to it depends of the configuration of the app’s build pipeline. We’ll use the TypeScript Express sample project as an example here.įirst, we need to compile the app to JavaScript. To enable source map generation, add "sourceMap": true in the tsconfig.json file.

webstorm nodejs debug webstorm nodejs debug

The TypeScript compiler can generate the source maps. WebStorm’s debugger will use them to map the compiled code that is executed to the source code in the editor, and you will be able to put breakpoints in TypeScript code and step through it. There’s one extra thing you need for that – Source Maps. With WebStorm you can also debug code written in TypeScript (though you need to compile it to JavaScript first to run it with node). For any earlier versions it will use the old options and protocol. WebStorm will check the node version you’re using and if it’s 8+, it will use the new options and protocol. With WebStorm, you don’t have to worry about the protocols and options. The command-line options that you need to use to start debugging have changed to -inspect and -inspect-brk. Debugging protocolsĪs you may know, in version 7+ Node.js changed its debugging protocol to the Chrome Debugging Protocol. Tip: another way to quickly run or debug a Node.js file is using the Run or Debug actions in the context menu of the JavaScript file. 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. Now if you do the actions that trigger the code where the breakpoint is, the app will pause on the breakpoint. If you just want to run the app, click the green run icon next instead or press Ctrl-D / Shift + F10.Now press Ctrl-D on macOS or Shift+F9 on Windows & Linux to debug the app (or click the green bug-like icon).

webstorm nodejs debug

  • Now specify the path to the main file of the application that starts it.
  • To create a configuration, go to the Run menu and select Edit configurations… Click the + icon and select Node.js configuration type.
  • 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. We’ll use a simple Express app as an example. And you can start debugging your app very quickly.

    WEBSTORM NODEJS DEBUG HOW TO

    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 – read more about that in the How to debug with WebStorm blog post. You can do many things that will help you explore the code and understand where the bug is. You can put breakpoints right in your source code (no more debugger and console.log() statements!), which can be written in JavaScript or TypeScript. WebStorm makes it easier to debug Node.js apps.

  • Running node apps in Docker from WebStorm.
  • Attaching debugger to the running node process.





  • Webstorm nodejs debug