【ask】webstorm调试node单个js文件

The procedure falls into two parts: first we start an application as usual and then connect to it with the debugger.

  1. Set the breakpoints in the Node.js code, where necessary. At least one breakpoint is necessary otherwise the program will be just executed. If you want the debugging tool to stop at the first line of your code, set a breakpoint at the first line.
  2.  Create a Node.js run configuration with the following option in the Node parameters text box: --debug-brk==<port for connect to debugger remotely>

    Note

    • The --debug-brk option allows you to debug the code executed on start.
    • The --debug option is useful when you are not going to debug Node.js right now, but you want to debug it later.
  3. Run the application with the created configuration.
  4. Create a Node.js Remote Debug configuration: in the Debug port text box, type the port number specified in the currently running Node.js configuration.
  5. With the application still running, launch the Node.js Remote Debug configuration (select the configuration in the list and click the Debug toolbar button debug.png).
  6. In the Run tool window, copy the URL address of the server and open the corresponding page in the browser. Control over the debugging session returns to WebStorm.
  7. Switch to WebStorm. In the Debug tool window, step through the breakpoints, switch between frames, change values on-the-fly, examine a suspended programevaluate expressions, and set watches.

posted on 2013-09-26 10:49  南原始天  阅读(669)  评论(0编辑  收藏  举报