Home >Development Tools >VSCode >Detailed explanation of how to debug Node.js in vscode

Detailed explanation of how to debug Node.js in vscode

青灯夜游
青灯夜游forward
2021-04-08 11:43:217124browse

This article will introduce to you how to debug Node.js in vscode. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

Detailed explanation of how to debug Node.js in vscode

Recommended learning: "vscode tutorial", "nodejs tutorial"

Debug Node.js in vscode

1. First remember which is the startup file

Detailed explanation of how to debug Node.js in vscode

2. Click this and then this

Detailed explanation of how to debug Node.js in vscode

3. Click on this

Detailed explanation of how to debug Node.js in vscode

4. Click on this

Detailed explanation of how to debug Node.js in vscode

5. vscode will automatically create the debug configuration file of launch.json for you

The four attributes are the most important, type, request, name and program
type is the type of language. Such as PHP, Java, Node.js, etc.

request is the type of debug. There are two debug types in vscode, launch and attach. We only need to know the type of launch

name is the configuration name, used to distinguish different configurations

program is the startup file, our startup file is under ${workspaceFolder}/bin/www.js, so we need to change it

Detailed explanation of how to debug Node.js in vscode

6. Change it to this

Detailed explanation of how to debug Node.js in vscode

7. The breakpoint of this breakpoint

Detailed explanation of how to debug Node.js in vscode

8. Click this to start debugging

Detailed explanation of how to debug Node.js in vscode

##9. On the left are variables, on the right are debug controllers, and below are the output and debugging consoles

debug controllers : The first one is to continue execution until the next breakpoint. The second one is single-step skipping, that is, continue to execute the next line of code (without jumping into the function). The third one is single-step debugging, that is, jump into the function and execute The first line of code of the function. The fourth is to single-step out, that is, execute the remaining part of the function and jump out of the function.

The bottom line of the debug controller can be console.log() or directly enter variables You can use the command named to view properties, and you can also execute code, such as assigning values ​​to variables

Detailed explanation of how to debug Node.js in vscode

For more programming-related knowledge, please visit:

Programming Video! !

The above is the detailed content of Detailed explanation of how to debug Node.js in vscode. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete