Launch file interpretation

Required properties:

1. Type: The type of the debugger used to launch the configuration. The following are the built-in types provided by VS Code, as well as others like PWA-node, which is provided by plugins for PWA-chrome

  • node
  • php
  • go
  • chrome

2. Request: The request type of the launch configuration. Currently, launch and attach are supported

  • Launch — This is most often used for applications that have not been launched
  • Attach — This is usually used for processing a program that has already been started

3. Name: Custom name used to distinguish different debug configurations (shown in the Debug Launch Configuration drop-down list)

Common optional properties

1. Presentation: Presentation (in debug startup configuration)

  • Order: sort the position
  • Hidden: Whether or not to hide
  • Group: group

PostDebugTask: A task that is launched at the end of the debug session. 4. InternalConsoleOptions: This property controls the visibility of the debug console panel during the debug session

  • Neveropen: Never open
  • OpenOnSessionStart: Open when starting a session
  • OpenOnFirstSessionStart: Open when starting the first session

Partially optional properties

2. Args: Parameters passed to the program 3. Env: environment variable 4. Envfile: path to the environment variable file 5. Cwd: current working directory to find dependencies and other files 6. Port: Port when connecting to a running process 7. StopOnEntry: Stop immediately when the program starts 8. Console: The way to use Console

  • internalConsole
  • integratedTerminal
  • externalTerminal

Some variablesThe document

  1. ${workspaceFolder}: The root path of the workspace folder
  2. ${file}: the editorThe file in the current window is openThe path of the

Debugging nodejs

Note: You cannot use ES Module (import, export) to export NodeJS. Use CommonJS (require, module.exports).

Json file configuration:

{" version ":" 0.2.0, "" configurations: [{" type" : "node", "request" : "launch", "name" : "the debug nodejs", "CWD" : "${workspaceFolder}", // Set the default root path of the current debug file to ${workspaceFolder}" skipFiles": ["${workspaceFolder}/node_modules/**/*.js", // do not enter the program in node_modules "<node_internals>/**", // skip the internal node module program], "Program ": "debug.js", // The executable entry file must use the absolute path "NPM ", // Executes script defined in package.json: ["run-script", "debug"], // Executes script defined in package.json: // Executes script defined in package.json:]}

Complete code: click to access

Debugging TS program

Background: The path alias is configured in the tsconfig.json file in the project. If you use normal TSC to compile the program, you cannot resolve the path alias, so TS-node + tsconfig-paths/register is introduced to compile and execute the program

Note: TS-Node, TypeScript, TSCONFIG-PATHS need to be installed in the project dependencies

Json file configuration:

{" version ":" 0.2.0, "" configurations: [{" name" : "ts - node", / / custom name "type" : "node", / / built-in specific actuator "request" : "Launch ", "env": {"NODE_ENV": "test", // Set the node environment variable process.env.node_env to get this value}, "runtimeArgs": ["-r", "ts-node/register", "tsconfig-paths/register", "tsconfig-paths/register", "tsconfig-paths/register"], "skipFiles": ["${workspaceFolder}/modules/assistant/node_modules/**/*.js", // Skips programs in node_modules must use the absolute path "<node_internals>/**", // Skips the internal node module program], "CWD ": "${workspaceFolder}/modules/assistant", // The path to the module found in runtimeArgs is "protocol": "Inspector", "the program" : ". / test/photography. Spec. Ts ", / / joining together behind the path of CWD or using the absolute path "internalConsoleOptions" : "openOnSessionStart" } ] }

Complete code: click to access

Debugging ng&react

1. Install Debugger for Chrome

Json file configuration:

{" version ":" 0.2.0, "" configurations: [{" type" : "chrome", "request" : "launch", "name" : "the debug ng", / / custom name "url" : "http://localhost:4200", // Project startup address "skipFiles": ["${workspaceFolder}/node_modules/**/*.js", // do not enter the program in node_modules "<node_internals>/**", // skip the internal node module program]}]}

Complete code: click to access

Debugging python

Json file configuration:

"Configurations ": [{"name":" Python ", "type": "Python ", "request": "launch", "program": "configurations": ${workspaceFolder}/debug.py", // debug program "console": "IntegratedTerminal"}]}

Complete code: click to access

The resources

  1. Debugging
  2. Debugging in VS Code
  3. Node.js debugging in VS Code
  4. Variables Reference