Home > Development Tools > VSCode > body text

How to debug nodejs with breakpoints in vscode

青灯夜游
Release: 2021-06-02 19:45:44
forward
2503 people have browsed it

How to debug nodejs with breakpoints in vscode

In normal front-end development, the front-end code can be easily debugged with breakpoints on the browser. So if you want to debug the node backend interface, how to implement breakpoint debugging?

Configuration

vscodeOpen the node project and click the debug button on the left

How to debug nodejs with breakpoints in vscode

Click Run and Debug

How to debug nodejs with breakpoints in vscode

Select the language as nodejs

How to debug nodejs with breakpoints in vscode

Click the settings button to add configuration

How to debug nodejs with breakpoints in vscode

[Recommended learning: "vscode tutorial"]

Change the lanuch.json configuration file

How to debug nodejs with breakpoints in vscode

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项目的启动文件
Copy after login

Click the breakpoint debugging button again to start breakpoint debugging

How to debug nodejs with breakpoints in vscode

Click directly on the startup program to start breakpoint debugging

How to debug nodejs with breakpoints in vscode

Put a breakpoint mark directly on the left side of the code where a breakpoint is required. The execution method will automatically trigger the breakpoint

How to debug nodejs with breakpoints in vscode

and then pass the above Debug button step by step breakpoint

How to debug nodejs with breakpoints in vscode

You can also see the breakpoint data by hovering the mouse

How to debug nodejs with breakpoints in vscode

Of course, you can also The result of the debug console console outputting breakpoint data is equivalent to the browser breakpoint console console

How to debug nodejs with breakpoints in vscode

If you want to end the breakpoint, just click the pause button above

How to debug nodejs with breakpoints in vscode

The above is the tutorial for the entire vscode breakpoint configuration and breakpoint debugging

For more programming-related knowledge, please visit: Introduction to Programming! !

The above is the detailed content of How to debug nodejs with breakpoints in vscode. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!