在VSCode中设置TypeScript调试

时间:2019-02-03 19:25:24

标签: typescript debugging visual-studio-code

我过去24小时都在观看/阅读有关如何调试TypeScript中的VSCode的教程和帖子。但是我每次都失败了。

tsconfig.json

{
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "lib": [
            "es6",
            "dom"
        ],
        "sourceMap": true,
        "outDir": "./dist",
        "rootDir": "./src",
        "strict": true,
        "noImplicitAny": true,
        "strictNullChecks": true,
        "strictFunctionTypes": true,
        "strictPropertyInitialization": true,
        "noImplicitThis": true,
        "alwaysStrict": true,
        "noUnusedLocals": true,
        "noImplicitReturns": true,
        "esModuleInterop": true,
        "resolveJsonModule": true,
        "moduleResolution": "node"
    },
    "include": ["src/**/*.ts"],
    "exclude": ["node_modules"]
}

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Debug Node TS",
            "preLaunchTask": "typescript",
            "program": "node ${workspaceFolder}\\src\\app.ts",
            "cwd": "${workspaceFolder}",
            "protocol": "inspector",
            "outFiles": ["${workspaceFolder}\\dist\\**\\*.js"]
        }
    ]
}

task.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "typescript",
            "type": "npm",
            "script": "start-no-watch",
            "problemMatcher": []
        }
    ]
}

运行调试器时,它可以很好地运行服务器。但它从未达到任何断点。当停止服务器时,它会出错prelaunch terminated with exit code 1,然后单击Show ErrorsNo problem have been detected。除了把头撞在墙上,我还做错什么?

注意:请不要将其标记为重复项。我曾尝试过其他帖子,但感觉好像缺少了一些我不知道的小东西。

0 个答案:

没有答案