9

我在 Windows 10 机器上,VS Code with WSL 2 (Ubuntu 18.04) 试图使用Chrome 调试器扩展,但无济于事。以下是我的launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch index.html",
            "type": "chrome",
            "request": "launch",
            "file": "${workspaceFolder}/index.html",
            "runtimeExecutable": "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",
            "runtimeArgs": [" --remote-debugging-port=9222"],
            "userDataDir": "${workspaceFolder}/chrome",
            "port": 9222
        },
    ]
}

每当我按 F5 时,我都希望看到我的index.html页面加载到新的 Chrome 选项卡中,但它所做的只是启动一个新的空白 Chrome 窗口,然后每隔大约 15 秒就会弹出两个错误。

我不太关心第一个错误,它说Google Chrome cannot read and write to its data directory: <VALID-DIRECTORY-ON-MY-MACHINE>. 过去一天半以来我一直试图解决的是第二个错误,它说

Cannot connect to runtime process, timeout after 10000 ms - (reason: Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:9222)

我在 Stack、GitHub、VS Code 开发网站等上尝试了很多解决方案,但没有任何帮助。在我的 Chrome 浏览器上,http://localhost:9222/json抛出一些我理解为意味着浏览器应该可以连接的内容:

[ {
   "description": "",
   "devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:9222/devtools/page/E7E1DFE661F744BE79A572564251BC39",
   "id": "E7E1DFE661F744BE79A572564251BC39",
   "title": "New Tab",
   "type": "page",
   "url": "http://localhost:9222/json",
   "webSocketDebuggerUrl": "ws://localhost:9222/devtools/page/E7E1DFE661F744BE79A572564251BC39"
}, {
   "description": "",
   "devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:9222/devtools/page/C089932CAB5A26F4409B78F887C84A50",
   "id": "C089932CAB5A26F4409B78F887C84A50",
   "title": "about:blank",
   "type": "page",
   "url": "about:blank",
   "webSocketDebuggerUrl": "ws://localhost:9222/devtools/page/C089932CAB5A26F4409B78F887C84A50"
} ]

此外,我还在我的settings.json:"remote.extensionKind": {"msjsdiag.debugger-for-chrome": "workspace"}基于此推荐。我还重新启动了我的机器,启动 VS Code,然后启动(不打开任何其他 Chrome 窗口)。

似乎所有应该工作的东西都没有,这意味着我可能在这里误解了一些东西。我的问题是,我在这里做错了什么吗?

4

1 回答 1

0

这是vscode的一个错误。可以通过将扩展 'JavaScript Debugger' 替换为 'JavaScript Debugger (Nightly) '来解决此问题。见:https ://github.com/microsoft/vscode/issues/120227

于 2021-04-06T14:36:55.793 回答