我在Windows 10计算机上,尝试使用Chrome debugger extension的WSL 2(Ubuntu 18.04)VS Code,但无济于事。以下是我的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键时,就会在新的Chrome选项卡中加载
index.html
页,但是这样做只是启动一个新的空白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"
} ]
另外,我还基于此recommendation设置了
settings.json
:"remote.extensionKind": {"msjsdiag.debugger-for-chrome": "workspace"}
。我还重新启动了计算机,启动了VS Code,然后启动(没有打开任何其他Chrome窗口)。似乎所有应该工作的东西都不起作用,这意味着我可能在这里误解了一些东西。我的问题是,我在这里做错了什么吗?
最佳答案
这是vscode的错误。可以通过将扩展名'JavaScript Debugger'替换为'JavaScript Debugger (Nightly)'来解决此问题。
另请:https://github.com/microsoft/vscode/issues/120227
关于html - 带有VSCode上的Chrome调试器的WSL 2出现ECONNREFUSED错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61308034/