简体   繁体   English

VSCode在打字稿中设置断点

[英]VSCode set breakpoints in typescript

I want to debug typescript using vscode, I tried to set breakpoints in my typescript source file. 我想使用vscode调试打字稿,我试图在打字稿源文件中设置断点。 Here is my launch.json : 这是我的launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "program": "${file}",
            "outFiles": [
                "${workspaceRoot}/dist/**/*.js"
            ],
            "cwd": "${workspaceRoot}",
            "sourceMaps": true,
            "console": "integratedTerminal"
        }
    ]
}

and I use gulp to watch typescript and compile them to .js . 并且我使用gulp观看打字稿并将其编译为.js Here is tsconfig.json : 这是tsconfig.json

{
    "files": [
        "src/**/*.ts"
    ],
    "compilerOptions": {
        "module": "commonjs",
        "removeComments": true,
        "allowJs": true,
        "target": "es2015",
        "sourceMap": true,
        "types": [
            "node",
            "lodash"
        ]
    },
    "exclude": [
        "node_modules"
    ]
}

But when I set breakpoints in typescript file, there comes the error: cannt launch the program src/xxx.ts because corresponding JavaScript cannot be found. 但是,当我在打字稿文件中设置断点时,会出现错误: cannt launch the program src/xxx.ts because corresponding JavaScript cannot be found. I have checked that gulp has compiled .ts into dist/ 我检查了gulp是否已将.ts编译为dist/

Instead of 代替

"outFiles": [
    "${workspaceRoot}/dist/**/*.js"
],

You should use 你应该用

"outDir": "${workspaceRoot}/dist"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM