亚克力是什么材质| 耳朵痒是什么原因引起的| 益生菌治什么病| 咸鱼翻身是什么意思| sn是什么| 枇杷不能和什么一起吃| 糖尿病筛查做什么检查| 纳闷是什么意思| 心影增大是什么意思| 什么是前鼻音和后鼻音| 铁什么时候吃| 梦见新房子是什么意思| 金银花什么时候开花| power是什么牌子| 什么不生四字成语| 牙痛安又叫什么| 美国为什么那么强大| 肺结核的痰是什么颜色| 吃什么提高免疫力最好最快| 小便出血是什么原因| 狗尾续貂什么意思| 特长有什么| 骨髓炎是什么症状| 湿气用什么药最好最快| a2是什么意思| 中性粒细胞偏低是什么意思| 尿频是什么症状| 春梦是什么| 警犬都是什么品种| 你害怕什么| 什么是再生纤维素纤维| 晕车药什么时候吃最好| 亲子鉴定去医院挂什么科| 按摩椅什么牌子最好| 知了为什么叫| 刮痧出痧说明什么| 关节痛挂号挂什么科| 放屁多是什么原因引起的| 11月12日什么星座| 白细胞低是怎么回事有什么危害| siri什么意思| 小孩抽多动症吃什么药最好| 倍他乐克是什么药| 感冒了喝什么汤好| 锆石是什么| 慢性肠炎吃什么药效果好| 孕妇贫血吃什么药| 孕妇什么时候有奶水| 鞭长莫及什么意思| 1977年是什么年| 五花肉和什么菜炒好吃| 妈妈最大的愿望是什么| hhh是什么意思| 大学体检都检查什么| 不知道吃什么怎么办| 高血压和高血脂有什么区别| 染指是什么意思| 车抛锚是什么意思| 女人梦到蛇预示着什么| 麦粒肿不能吃什么食物| 铋剂是什么药| 什么车不能开| 幼字五行属什么| 萤火虫为什么会发光简单回答| 室间隔增厚是什么意思| 核素治疗是什么| 热毛巾敷眼睛有什么好处| 官方的意思是什么| 欢字五行属什么| 肾不好是什么原因引起的| 小猫来家里有什么预兆| 小暑是什么意思| 肠胃不好吃什么水果比较好| 维生素d3是什么| 秋天穿什么衣服| o型血和b型血生的孩子是什么血型| 志愿号是什么意思| 哈密瓜为什么会苦| 什么算熬夜| 梅开二度是什么意思| 涛字五行属什么| 蝗虫吃什么| 清洁度1度是什么意思| 角膜炎吃什么药| 小孩黑眼圈很重是什么原因| 陆代表什么生肖| 大姨妈来了喝红糖水有什么功效| 腺样体肥大是什么症状| 脂肪酶是什么| 常乐我净是什么意思| 拔牙后喝酒有什么危害| 郭五行属什么| 月经多是什么原因| 肌酐偏低是什么意思| 今年65岁属什么生肖| 舍什么为什么| 血糖是什么| 为什么会生化妊娠| 坐月子吃什么补气血| 阴道吹气是什么原因| 煞气是什么意思| 山药和什么不能一起吃| 婴儿血小板低是什么原因| 氯化钠敷脸有什么作用| 花中皇后是什么花| 邦字五行属什么| 丹参长什么样子图片| 阴茎出血是什么原因| 什么是心理健康| 岳绮罗是什么来历| 苍蝇最怕什么| 小时的单位是什么| 吃了避孕药后几天出血是什么原因| 两个山念什么| 3朵玫瑰代表什么意思| 心咒是什么意思| 直女是什么意思| 痱子长什么样| 攻心翻是什么病| 为什么膝盖弯曲就疼痛| 恢复伤口吃什么好得快| 查血脂挂什么科| 产后能吃什么水果| 女生白带是什么| 精子碎片率高吃什么药| 梦见老公出轨预示什么| 青光眼什么症状| 毕业花束选什么花| 孽债是什么意思| 结膜炎用什么药| 打激素有什么副作用| 洗澡用什么香皂好| 增加性功能吃什么药| 艾灸是什么意思| 导师是什么意思| 春天有什么动物| 母亲节送妈妈什么| 腊月二十三是什么星座| 什么清肠茶好| 股骨头疼痛什么原因| 什么治便秘| 喝什么可以降血压| dr是什么意思| 离卦代表什么| 低烧是什么症状| 什么原因导致尿酸高| 精囊腺囊肿是什么意思| runosd是什么牌子的手表| 十月十三是什么星座| 你喜欢我什么我改| 寻的部首是什么| 人外是什么意思| 三点水及念什么| 银环蛇咬伤后什么症状| 胃老是恶心想吐是什么原因| 除体内湿热最好的中成药是什么| 7.11是什么日子| 子女缘薄是什么意思| 怀孕10多天有什么症状| 给你脸了是什么意思| grace什么意思| 长期口臭要看什么科| 紫外线过敏吃什么药| 事业有成是什么意思| 58是什么意思| 大耳朵狗叫什么| 地三鲜是什么菜| 胆囊结石吃什么食物好| 什么叫反式脂肪| 什么人一年只工作一天| 利尿是什么意思| 创伤性关节炎有什么症状| 骨质增生吃什么药效果好| 11月21日什么星座| 脚筋疼是什么原因| 内心os什么意思| 什么是预防医学| 警察是什么生肖| 四十不惑是什么意思| 痰栓是什么意思| 处女座前面是什么星座| 胃不好应该吃什么| 孕妇胃疼可以吃什么药| 李字五行属什么| k值是什么意思| 病退需要什么条件| 恩裳是什么档次的衣服| 赟怎么读 什么意思| 泌尿系统感染吃什么消炎药| 宠物医院需要什么资质| 尿潜血阳性什么意思| 镇委书记是什么级别| 手心脚心发热是什么原因引起的| 丝瓜为什么会苦| 狒狒是什么意思| 蜂鸟是什么鸟| 经期洗头有什么危害| 靶向药是什么药| 元帅相当于现在什么官| 什么相争| 老死不相往来什么意思| 十二指肠溃疡吃什么中成药| 为什么想到一个人会心痛| 全身发痒是什么原因| 鱼跳出鱼缸有什么征兆| 侵犯什么意思| 丰胸吃什么| 低密度脂蛋白胆固醇高是什么意思| 左顾右盼的顾是什么意思| 吃坏肚子了吃什么药| 类风湿不能吃什么| 透析是什么意思啊| 身份证穿什么颜色的衣服| 诺如病毒吃什么药好得快一点| 软肋骨炎吃什么药对症| hpv16阳性有什么症状| 情投意合是什么意思| vaude是什么品牌| 复方血栓通片功效作用治疗什么病| 胃不舒服想吐吃什么药| 纤维硬结灶是什么意思| 满江红是什么植物| 蜂胶是什么东西| 木舌是什么字| 男性腰疼挂什么科| 颈动脉斑块吃什么药好| 独角仙吃什么| 沙门是什么意思| 雉是什么动物| 23是什么生肖| 肺慢阻是什么情况| 家是什么| icicle是什么牌子| 喝酒对身体有什么危害| 尿素高什么原因| lxy是什么意思| 狗狗细小是什么症状| 猜忌是什么意思| 一条什么| 盛世美颜是什么意思| 蛇生肖和什么生肖相配| 没什么大不了的| 北京晚上有什么好玩的景点| 什么是人彘| iac是什么意思| 夜场是什么工作| 喝什么降血糖| 猫不能吃什么东西| 胃不好能吃什么水果| 入殓师是做什么的| 梦见自己请客吃饭是什么意思| 每年什么时候最热| 青蒜是什么| 看心脏挂什么科| 心脾两虚吃什么食物补最快| 口干舌燥是什么意思| 脾胃有火是什么症状| 巴西龟吃什么食物| 不安腿是什么症状| 阑尾炎手术后可以吃什么水果| 80是什么意思| 什么样才是包皮| 吃什么补肾壮阳最快速| 血尿是什么原因引起的男性| 百度

Try to extend agent mode in VS Code!

海南入河排污口调查摸底和规范整治专项行动启动

百度 但问及何时兴建,何人雕造,均无人知晓。

For complex debugging scenarios or applications, you need to create a launch.json file to specify the debugger configuration. For example, to specify the application entry point, attach to a running application, or to set environment variables.

To learn more about debugging in VS Code, see Debugging in Visual Studio Code.

Tip

Copilot in VS Code can help you create a launch configuration for your project. Get more info about generating a launch configuration with Copilot.

Launch configurations

For simple applications or debugging scenarios, you can run and debug a program without specific debugging configurations. Use the F5 key and VS Code will try to run your currently active file.

However, for most debugging scenarios you need to create a debugging configuration (launch configuration). For example, to specify the application entry point, attach to a running application, or set environment variables. Creating a launch configuration file is also beneficial because it allows you to configure and save debugging setup details with your project.

VS Code stores debugging configuration information in a launch.json file located in the .vscode folder in your workspace (project root folder), or in your user settings or workspace settings.

The following snippet describes a sample configuration for debugging a Node.js application:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Launch Program",
      "skipFiles": ["<node_internals>/**"],
      "program": "${workspaceFolder}\\app.js"
    }
  ]
}

VS Code also supports compound launch configurations for starting multiple configurations at the same time.

Note

You can debug a simple application even if you don't have a folder open in VS Code, but it is not possible to manage launch configurations and set up advanced debugging.

Create a debug configuration file

To create an initial launch.json file:

  1. Select create a launch.json file in the Run and Debug view.

    launch configuration

  2. VS Code tries to detect your debug environment. If it's unable to do so, you can choose it manually:

    debug environment selector

    Based on the selected debug environment, VS Code creates a starter configuration in the launch.json file.

  3. In the Explorer view (??E (Windows, Linux Ctrl+Shift+E)), notice that VS Code created a .vscode folder and added the launch.json file to your workspace.

    launch.json in Explorer

You can now edit the launch.json file to add more configurations or modify existing ones.

Add a configuration to launch.json

To add a new configuration to an existing launch.json, use one of the following techniques:

  • Press the Add Configuration button and then select a snippet to add a predefined configuration.
  • Use IntelliSense if your cursor is located inside the configurations array.
  • Choose the Run > Add Configuration menu option.

launch json suggestions

Generate a launch configuration with AI

With Copilot in VS Code, you can accelerate the process of creating a launch configuration for your project. To generate a launch configuration with Copilot:

  1. Open the Chat view with ??I (Windows, Linux Ctrl+Alt+I), or select Open Chat from the Copilot menu in the title bar.

  2. Enter the /startDebugging chat prompt to generate a debug configuration.

    Alternatively, you can also enter a custom prompt, like generate a debug config for an express app #codebase.

    This can be useful if your workspace has files with different languages.

    Note

    The #codebase chat variable gives Copilot the context of your project, which helps it generate a more accurate response.

  3. Apply the suggested configuration, and then start debugging.

Start a debugging session with a launch configuration

To start a debug session with a launch configuration:

  1. Select the configuration named Launch Program using the Configuration dropdown in the Run and Debug view.

    The list of available configurations matches those in the launch.json file.

    Screenshot that shows the launch configuration dropdown.

  2. Start your debug session with F5 or select Start Debugging (play icon) in Run and Debug view.

Alternatively, you can run your configuration through the Command Palette (??P (Windows, Linux Ctrl+Shift+P)) by filtering on Debug: Select and Start Debugging or typing 'debug ' and selecting the configuration you want to debug.

Launch versus attach configurations

In VS Code, there are two core debugging modes, Launch and Attach, which handle two different workflows and segments of developers. Depending on your workflow, it can be confusing to know what type of configuration is appropriate for your project.

If you come from a browser Developer Tools background, you might not be used to "launching from your tool," since your browser instance is already open. When you open DevTools, you are simply attaching DevTools to your open browser tab. On the other hand, if you come from a server or desktop background, it's quite normal to have your editor launch your process for you, and your editor automatically attaches its debugger to the newly launched process.

The best way to explain the difference between launch and attach is to think of a launch configuration as a recipe for how to start your app in debug mode before VS Code attaches to it, while an attach configuration is a recipe for how to connect VS Code's debugger to an app or process that's already running.

VS Code debuggers typically support launching a program in debug mode or attaching to an already running program in debug mode. Depending on the request (attach or launch), different attributes are required, and VS Code's launch.json validation and suggestions should help with that.

Launch.json attributes

There are many launch.json attributes to help support different debuggers and debugging scenarios. You can use IntelliSense (?Space (Windows, Linux Ctrl+Space)) to see the list of available attributes once you have specified a value for the type attribute. The attributes available in launch configurations vary from debugger to debugger.

launch json suggestions

An attribute that is available for one debugger doesn't automatically work for other debuggers too. If you see red squiggles in your launch configuration, hover over them to learn what the problem is and try to fix them before launching a debug session.

The following attributes are mandatory for every launch configuration:

  • type - the type of debugger to use for this launch configuration. Every installed debug extension introduces a type: node for the built-in Node debugger, for example, or php and go for the PHP and Go extensions.
  • request - the request type of this launch configuration. Currently, launch and attach are supported.
  • name - the reader-friendly name to appear in the Debug launch configuration dropdown.

Here are some optional attributes available to all launch configurations:

  • presentation - using the order, group, and hidden attributes in the presentation object, you can sort, group, and hide configurations and compounds in the Debug configuration dropdown and in the Debug quick pick.
  • preLaunchTask - to launch a task before the start of a debug session, set this attribute to the label of a task specified in tasks.json (in the workspace's .vscode folder). Or, this can be set to ${defaultBuildTask} to use your default build task.
  • postDebugTask - to launch a task at the very end of a debug session, set this attribute to the name of a task specified in tasks.json (in the workspace's .vscode folder).
  • internalConsoleOptions - this attribute controls the visibility of the Debug console panel during a debugging session.
  • debugServer - for debug extension authors only: this attribute allows you to connect to a specified port instead of launching the debug adapter.
  • serverReadyAction - if you want to open a URL in a web browser whenever the program under debugging outputs a specific message to the debug console or integrated terminal. For details see section Automatically open a URI when debugging a server program below.

Many debuggers support some of the following attributes:

  • program - executable or file to run when launching the debugger
  • args - arguments passed to the program to debug
  • env - environment variables (the value null can be used to "undefine" a variable)
  • envFile - path to dotenv file with environment variables
  • cwd - current working directory for finding dependencies and other files
  • port - port when attaching to a running process
  • stopOnEntry - break immediately when the program launches
  • console - what kind of console to use, for example, internalConsole, integratedTerminal, or externalTerminal

Variable substitution

VS Code makes commonly used paths and other values available as variables and supports variable substitution inside strings in launch.json. This means that you do not have to use absolute paths in debug configurations. For example, ${workspaceFolder} gives the root path of a workspace folder, ${file} the file open in the active editor, and ${env:Name} the environment variable 'Name'.

You can see a full list of predefined variables in the Variables Reference or by invoking IntelliSense inside the launch.json string attributes.

{
  "type": "node",
  "request": "launch",
  "name": "Launch Program",
  "program": "${workspaceFolder}/app.js",
  "cwd": "${workspaceFolder}",
  "args": ["${env:USERNAME}"]
}

Platform-specific properties

VS Code supports defining debugging configuration settings (for example, arguments to be passed to the program) that depend on the operating system where the debugger is running. To do so, put a platform-specific literal in the launch.json file and specify the corresponding properties inside that literal.

The following example shows how to pass "args" to the program differently on Windows:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Launch Program",
      "program": "${workspaceFolder}/node_modules/gulp/bin/gulpfile.js",
      "args": ["myFolder/path/app.js"],
      "windows": {
        "args": ["myFolder\\path\\app.js"]
      }
    }
  ]
}

Valid operating system properties are "windows" for Windows, "linux" for Linux, and "osx" for macOS. Properties defined in an operating system specific scope override properties defined in the global scope.

The type property cannot be placed inside a platform-specific section because type indirectly determines the platform in remote debugging scenarios, which would result in a cyclic dependency.

In the following example, debugging the program always stops on entry, except on macOS:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Launch Program",
      "program": "${workspaceFolder}/node_modules/gulp/bin/gulpfile.js",
      "stopOnEntry": true,
      "osx": {
        "stopOnEntry": false
      }
    }
  ]
}

Global launch configuration

You can define launch configurations that are available across all your workspaces. To specify a global launch configuration, add a launch configuration object in your launch user setting. This launch configuration is then shared across your workspaces. For example:

"launch": {
    "version": "0.2.0",
    "configurations": [{
        "type": "node",
        "request": "launch",
        "name": "Launch Program",
        "program": "${file}"
    }]
}

Redirect input/output to/from the debug target

Redirecting input/output is debugger or runtime specific, so VS Code does not have a built-in solution that works for all debuggers.

Here are two approaches you might want to consider:

  • Launch the program to debug ("debug target") manually in a terminal or command prompt and redirect input/output as needed. Ensure that you pass the appropriate command line options to the debug target so that a debugger can attach to it. Create and run an "attach" debug configuration that attaches to the debug target.

  • If the debugger extension you are using can run the debug target in VS Code's Integrated Terminal (or an external terminal), you can try to pass the shell redirect syntax (for example, "<" or ">") as arguments.

    Here's an example launch.json configuration:

    {
      "name": "launch program that reads a file from stdin",
      "type": "node",
      "request": "launch",
      "program": "program.js",
      "console": "integratedTerminal",
      "args": ["<", "in.txt"]
    }
    

    This approach requires that the < syntax is passed through the debugger extension and ends up unmodified in the Integrated Terminal.

Compound launch configurations

An alternative way to start multiple debug sessions is by using a compound launch configuration. You can define compound launch configurations in the compounds property in the launch.json file.

Use the configurations attribute to list the names of two or more launch configurations that should be launched in parallel.

Optionally, specify a preLaunchTask task that is run before the individual debug sessions are started. The boolean flag stopAll controls whether manually terminating one session stops all of the compound sessions.

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Server",
      "program": "${workspaceFolder}/server.js"
    },
    {
      "type": "node",
      "request": "launch",
      "name": "Client",
      "program": "${workspaceFolder}/client.js"
    }
  ],
  "compounds": [
    {
      "name": "Server/Client",
      "configurations": ["Server", "Client"],
      "preLaunchTask": "${defaultBuildTask}",
      "stopAll": true
    }
  ]
}

Compound launch configurations are also displayed in the launch configuration dropdown menu.

Automatically open a URI when debugging a server program

Developing a web program typically requires opening a specific URL in a web browser in order to hit the server code in the debugger. VS Code has a built-in feature "serverReadyAction" to automate this task.

Here is an example of a simple Node.js Express application:

var express = require('express');
var app = express();

app.get('/', function(req, res) {
  res.send('Hello World!');
});

app.listen(3000, function() {
  console.log('Example app listening on port 3000!');
});

This application first installs a "Hello World" handler for the "/" URL and then starts to listen for HTTP connections on port 3000. The port is announced in the Debug Console, and typically, the developer would now type http://localhost:3000 into their browser application.

The serverReadyAction feature makes it possible to add a structured property serverReadyAction to any launch config and select an "action" to be performed:

{
  "type": "node",
  "request": "launch",
  "name": "Launch Program",
  "program": "${workspaceFolder}/app.js",

  "serverReadyAction": {
    "pattern": "listening on port ([0-9]+)",
    "uriFormat": "http://localhost:%s",
    "action": "openExternally"
  }
}

Here the pattern property describes the regular expression for matching the program's output string that announces the port. The pattern for the port number is put into parenthesis so that it is available as a regular expression capture group. In this example, we are extracting only the port number, but it is also possible to extract a full URI.

The uriFormat property describes how the port number is turned into a URI. The first %s is substituted by the first capture group of the matching pattern.

The resulting URI is then opened outside of VS Code ("externally") with the standard application configured for the URI's scheme.

Trigger debugging via Microsoft Edge or Chrome

Alternatively, the action can be set to debugWithEdge or debugWithChrome. In this mode, a webRoot property can be added that is passed to the Chrome or Microsoft Edge debug session.

To simplify things a bit, most properties are optional and we use the following fallback values:

  • pattern: "listening on.* (http?://\\S+|[0-9]+)" which matches the commonly used messages "listening on port 3000" or "Now listening on: http://localhost:5001".
  • uriFormat: "http://localhost:%s"
  • webRoot: "${workspaceFolder}"

Triggering an arbitrary launch config

In some cases, you might need to configure more options for the browser debug session, or use a different debugger entirely. You can do this by setting action to startDebugging with a name property set to the name of the launch configuration to start when the pattern is matched.

The named launch configuration must be in the same file or folder as the one with the serverReadyAction.

Here the serverReadyAction feature in action:

Next steps

  • Tasks - Describes how to run tasks with Gulp, Grunt, and Jake and how to show errors and warnings.
  • Variables Reference - Describes the variables available in VS Code.

Common questions

I do not see any launch configurations in the Run and Debug view dropdown. What is wrong?

The most common problem is that you did not set up launch.json or there is a syntax error in that file. Alternatively, you might need to open a folder, since no-folder debugging does not support launch configurations.

手指麻是什么原因 为什么长痱子 搭桥是什么意思 淋巴细胞偏高是什么原因 水煎服是什么意思
数字是什么意思 长痘痘用什么药 干眼症滴什么眼药水好 语迟则人贵是什么意思 什么是反流性食管炎
眼睛出现飞蚊症什么原因怎么办 2005年属什么 8月6日是什么星座 事宜是什么意思 复原是什么意思
间接胆红素偏高是什么意思 鸡血藤长什么样子图片 极化是什么意思 黄瓜什么时候种植 酸奶和牛奶有什么区别
十月二十六是什么星座hcv8jop3ns8r.cn 1月22日是什么星座hcv8jop9ns2r.cn 关节炎用什么药hcv8jop0ns8r.cn 精梳棉是什么面料cl108k.com 开车穿什么鞋子hcv9jop6ns6r.cn
为什么智齿老是发炎hcv9jop5ns5r.cn fa是什么jiuxinfghf.com 乙醇是什么hcv7jop6ns5r.cn 医保统筹支付什么意思hcv9jop0ns2r.cn 落子是什么意思hcv7jop4ns6r.cn
孕吐什么时候出现hcv7jop9ns2r.cn 小腿为什么会抽筋hcv8jop4ns0r.cn hcg是什么激素hcv8jop4ns4r.cn 油炸食品用什么油最好yanzhenzixun.com 心肌炎有什么症状hcv8jop5ns3r.cn
肠胃不好经常拉肚子吃什么药hcv8jop1ns4r.cn 男人梦见蛇是什么征兆hcv9jop7ns3r.cn 68岁属什么生肖hcv7jop7ns2r.cn 风凉话是什么意思hcv9jop2ns5r.cn 白带有血丝是什么原因hcv9jop3ns6r.cn
百度