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

Sib*_*enu 6 json typescript visual-studio-code vscode-settings vscode-debugger

我只是想一些基本的配置添加到我的launch.json文件vscode,但我得到一个错误的属性参数表是不允许的。下面是我的配置。

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "attach",
            "name": "index",         
            "args": [
                "src/index.ts"
            ],
            "cwd": "${workspaceFolder}"           
        }
    ],
    "compounds": []
}
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

Sib*_*enu 6

那是一个愚蠢的错误。根据这个文档

VS Code 调试器通常支持在调试模式下启动程序或在调试模式下附加到已运行的程序。根据请求(附加或启动),需要不同的属性,VS Code 的 launch.json 验证和建议应该对此有所帮助。

所以当我将请求更改为launch from时attach,一切都很完美。仅请求类型launch支持配置args

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "index",         
            "args": [
                "src/index.ts"
            ],
            "cwd": "${workspaceFolder}"           
        }
    ],
    "compounds": []
}
Run Code Online (Sandbox Code Playgroud)