typescript - 无法在 TypeScript 中调试 - VS Code

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

由于某些错误,我无法打开 localhost,也无法在 VS Code 中调试 TypeScript 文件。我已将目标设置为“C:\Program Files (x86)\Google\Chrome\Application\chrome.exe”“--remote-debugging-port=9222”Chrome 属性中。我收到的错误为 [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/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>

最佳答案

没有直接回答问题,但也许仍然有用:您是否知道可以直接在 Chrome 中调试 typescript ,包括断点?您甚至不需要安装插件。 请参阅此屏幕截图:

enter image description here

关于typescript - 无法在 TypeScript 中调试 - VS Code,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38110019/

相关文章:

typescript - MarkerCluster LeafletJS 插件 TypeScript 定义文件创建

nativescript - 为什么更改的文本未反射(reflect)到 viewmodel 属性

iOS 如何使用nativescript-audio插件播放网络广播流?

javascript - 创建一个 d.ts 文件到 UnityLoader.js (Unity3D)

reactjs - 使用 preloadedState : redux store gets out of sync when having a manual import of store in a function 在 React 中进行测试

javascript - TypeScript 说一个字符串是无效的,即使它在联合中?

c++ - Visual Studio Code 中的编译错误

visual-studio-code - 无法启动 VSC

python - 如何在 VS Code 和 PyCharm 上显示图像?

ios - Nativescript IOS : Textview not resizing after Input was cleared