在 Visual Studio Code 中同时运行两个项目

问题描述 投票:0回答:1

我正在开发一个网络项目。服务器是一个用 TypeScript 编写的 Node.js 应用程序。客户端也是用 Typescript 编写的。 我需要:

  1. 在不同的文件夹中使用不同的编译器选项编译不同的项目,并且
  2. 同时调试两个项目。

我该怎么做?

visual-studio-code
1个回答
86
投票

请参阅我们有关多目标调试的文档:https://code.visualstudio.com/Docs/editor/debugging#_multitarget-debugging

在您的

launch.json
中,只需创建一个
compounds
部分,其中包含您要调试的目标

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Server",
            "program": "${workspaceRoot}/server.js",
            "cwd": "${workspaceRoot}"
        },
        {
            "type": "node",
            "request": "launch",
            "name": "Client",
            "program": "${workspaceRoot}/client.js",
            "cwd": "${workspaceRoot}"
        }
    ],
    "compounds": [
        {
            "name": "Server/Client",
            "configurations": ["Server", "Client"]
        }
    ]
}
© www.soinside.com 2019 - 2024. All rights reserved.