无法在TypeScript中调试 - VS Code

时间:2016-06-29 21:05:24

标签: typescript visual-studio-code nativescript vscode-debugger

由于某些错误,我无法打开localhost并无法在VS Code中调试TypeScript文件。我已在 Chrome属性中将目标设置为"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" "--remote-debugging-port=9222"。我得到的错误为[debugger-for-chrome] Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:9222。在终止所有chrome.exe进程后,请参阅以下图像以查找错误。有人可以帮我解决这个问题吗?提前致谢。

Failed to Load Error

.vscode / launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch index.html with sourcemaps",
            "type": "chrome",
            "request": "launch",
            "file": "${workspaceRoot}/index.html",
            "sourceMaps": true,
            "webRoot": "${workspaceRoot}"
        },
        {
            "name": "Launch localhost with sourcemaps",
            "type": "chrome",
            "request": "launch",
            "url": "http://localhost:3000",
            "sourceMaps": true,
            "webRoot": "${workspaceRoot}"
        },
        {
            "name": "Attach with sourcemaps",
            "type": "chrome",
            "request": "attach",
            "port": 9222,
            "sourceMaps": true,
            "webRoot": "${workspaceRoot}"
        }
    ]
}

tsconfig.json:

{
    "compilerOptions": {
        "target": "es5",
        "sourceMap": true
    }
}

应用/ app.ts:

var x = 1;
console.log(x); //made debugger here in VS Code

的index.html:

<!doctype html>
<html>
<body>
    <h3>TypeScript Debugger</h3>

    <script src="app/app.js"></script>
</body>
</html>

1 个答案:

答案 0 :(得分:2)

不直接回答问题,但可能仍然有用:您是否知道可以直接在Chrome中调试打字稿,包括断点?你甚至不需要安装插件。 见这个截图:

enter image description here