我只是这样做,因为我在Mac上使用Chrome进行调试,而且我不知道如何在Mac上禁用Chrome中的源 Map ,这导致调试非常错误 . See my question about that here . 但是当我尝试为Visual Studio Code启动Chrome调试器时,无论我尝试什么,我都会遇到此错误:

[debugger-for-chrome]无法连接到目标:connect ECONNREFUSED 127.0.0.1:9222

我主页的网址是http://localhost:3000/

我的launch.json文件是:

{
    "version": "0.1.0",
    "configurations": [
        {
            "name": "Launch localhost with sourcemaps",
            "type": "chrome",
            "request": "launch",
            "url": "http://localhost:3000",
            "webRoot": "${workspaceRoot}/js/app",
            "sourceMaps": true
        }
    ]
}

请注意我在以下方面尝试了一些值:

"webRoot": "${workspaceRoot}/js/app"

例如 ${workspaceRoot}/app ,其中包含我的打字稿 .

我的所有js都放在项目根目录中名为js的文件夹中,但如果可能的话,我想从typescript中调试?

这是我的项目结构:

enter image description here

如何让Chrome Debugger for Visual Studio Code正常工作?