6

我只是想在我的launch.json文件中添加一些基本配置,但由于不允许使用 Property argsvscode,所以出现错误。下面是我的配置。

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

在此处输入图像描述

4

1 回答 1

4

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

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

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

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "index",         
            "args": [
                "src/index.ts"
            ],
            "cwd": "${workspaceFolder}"           
        }
    ],
    "compounds": []
}
于 2018-06-24T05:15:43.460 回答