3

Preface

In the usual front-end development, the front-end code can be easily debugged with breakpoints in the browser. If you want to debug the node back-end interface, how to achieve breakpoint debugging?

Configuration

  1. vscode open the node project and click the debug button on the left
    image-20210422114604687
  2. Click Run and Debug
    image-20210422115211686
  3. Choose language as nodejs
    image-20210422115306221
  4. Click the Settings button to add configuration
    image-20210422115355821
  5. Change the lanuch.json configuration file
    image-20210422115449595
  6. Add your own project startup script file and configuration

    {
        // 使用 IntelliSense 了解相关属性。 
        // 悬停以查看现有属性的描述。
        // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
        "version": "0.2.0",
        "configurations": [
            {
                "type": "node",
                "request": "launch",
                "name": "启动程序",
                "env": {
                    "NODE_ENV": "development"
                },
                "program": "${workspaceFolder}/bin/www"
            }
        ]
    }
    //program这个是我自己的node项目的启动文件
  7. Click the breakpoint debugging button again to start breakpoint debugging
    image-20210422115727574
  8. Click the startup program directly to start the breakpoint debugging
    image-20210422141138335
  9. Mark the breakpoint directly on the left side of the code where the breakpoint is needed, the execution method is to automatically start the breakpoint
    image-20210422141453212
  10. Then breakpoint step by step through the debug button above
    image-20210422141603851
  11. You can also see the data of the breakpoint by hovering the mouse
    image-20210422141655187
  12. Of course, you can also output the breakpoint data in the debug console. The result is equivalent to the console console where the browser breakpoint is
    image-20210422141944344
  13. If you want to end the breakpoint, click the pause button above
    image-20210422141743539
  14. The above is the entire vscode breakpoint configuration and breakpoint debugging tutorial

兰俊秋雨
5.1k 声望3.5k 粉丝

基于大前端端技术的一些探索反思总结及讨论