Debug Node.js in vscode

  1. First remember which is the startup file
    Insert picture description here

  2. Click this and then click this
    Insert picture description here

  3. Click this
    Insert picture description here

  4. Click this
    Insert picture description here

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

    Four of the attributes are the most important, type, request, name and program
    type are the type of language, such as PHP, Java, Node.js, etc.

    Request is the type of debug. There are two types of debug 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
    Insert picture description here

  6. Change to this
    Insert picture description here

  7. The breakpoint of the breakpoint
    Insert picture description here

  8. Click this to start debugging
    Insert picture description here

  9. On the left is the variable, on the right is the debug controller, below is the output and debug console

    Debug controller: The first is to continue execution until the next breakpoint. The second is to step over, that is, continue to execute the next line of code (do not jump into the function). The third is to single step to debug, that is to jump into Function and execute the first line of code of the function. The fourth step is to step out, that is, execute the rest of the function and jump out of the function.

    The bottom line of the debug controller can be console.log() or directly input the command of the variable name to view the attributes, and the code can also be executed, such as assigning values ​​to the variables
    Insert picture description here

Guess you like

Origin blog.csdn.net/ef_ef/article/details/109411843