json - vscode 的 launch.json 中不允许使用属性参数

标签 json typescript visual-studio-code vscode-settings vscode-debugger

我只是想在 vscode 中向我的 launch.json 文件添加一些基本配置,但我收到错误消息,因为 Property args is not allowed . 下面是我的配置。

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "attach",
            "name": "index",         
            "args": [
                "src/index.ts"
            ],
            "cwd": "${workspaceFolder}"           
        }
    ],
    "compounds": []
}

enter image description here

最佳答案

这是一个愚蠢的错误。根据这个doc

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.

因此,当我将请求从 attach 更改为 launch 时,一切都很完美。只有请求类型launch支持配置args

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "index",         
            "args": [
                "src/index.ts"
            ],
            "cwd": "${workspaceFolder}"           
        }
    ],
    "compounds": []
}

关于json - vscode 的 launch.json 中不允许使用属性参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51007130/

相关文章:

.net - Json.NET 以最小的小数位数序列化 float/double,即没有冗余 ".0"?

Angular 2.1 - 在路由时重新创建组件

typescript - Visual Studio Code 使用的是哪个 TypeScript 版本?如何更新?

visual-studio-code - 在 VSCode 中匹配精确的字符串或单词

python - 在VsCode中编译python时的奇怪路径

javascript - 嵌套jquery有大量数据

javascript - 使用 for 循环在提要选项卡上生成列表项时访问嵌套的 url

typescript - 在 TypeScript 中通过装饰器向类添加属性

python - 在 VSC 中,如何在 Python 中重命名模块时激活 "refactor preview"?

ajax - jqplot 外部数据与异步调用?