You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在VS Code的launch.json中为单个调试任务指定cmd.exe作为Shell?

单个Node.js调试任务中指定cmd.exe作为Shell的实现方法

完全可行,无需修改全局设置,只需在项目.vscode/launch.json的目标调试配置中添加对应参数即可,以下提供两种常用方案:

方案一:指定调试用集成终端的Shell

适用于需要在集成终端中进行交互的调试场景,配置后该调试任务启动的终端会默认使用cmd.exe:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Launch Program",
      "program": "${workspaceFolder}/app.js",
      // 添加以下配置
      "terminal.integrated.defaultProfile.windows": "Command Prompt",
      "terminal.integrated.profiles.windows": {
        "Command Prompt": {
          "path": "cmd.exe"
        }
      }
    }
  ]
}

方案二:直接让Node.js调试进程通过cmd.exe启动

适用于无需终端交互,仅需用cmd.exe执行调试命令的场景:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Launch Program",
      "program": "${workspaceFolder}/app.js",
      // 添加以下配置
      "shell": true,
      "shellPath": "cmd.exe",
      "shellArgs": ["/c"]
    }
  ]
}

两种方案都只会对当前配置的调试任务生效,不会影响全局的终端默认设置。

内容的提问来源于stack exchange,提问作者Brad

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.02 14:22:15