我收到错误:无法连接到运行时进程,10000ms后超时-(原因:无法连接到目标)
NodeJs v4.3.1在WSL上运行。
下面是我的launch.json
"type": "node",
"request": "attach",
"name": "Attach to WSL",
"port": 3000,
"address": "localhost",
"restart": true,
"protocol": "inspector",
"localRoot": "${workspaceFolder}/web-frontend",
"remoteRoot": "/mnt/c/workspace/.../web-frontend"Ws1使用来自Windows的路径,因此localRoot和remoteRoot是相同的。
到目前为止,我还遗漏了什么?
发布于 2018-10-22 02:34:51
我创建了一个VS扩展:WSL workspaceFolder,它将帮助您自动将launch.json中的remoteRoot设置为正确的WSL路径。例如,我的launch.json,基于您的文件路径将如下所示;
/vscode/launch.json
{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "type": "node", "request": "attach", "name": "Attach to Remote", "address": "localhost", "port": 5858, "localRoot": "${workspaceFolder}/web-frontend", "remoteRoot": "${command:extension.vscode-wsl-workspaceFolder}/web-frontend" } ] }
然后,要启动调试会话,请在WSL终端中,在要调试的脚本的路径前输入NODE_ENV=debug node --nolazy --inspect-brk=5858。
但是,使用Node v4可能会遇到问题,因为它不支持“检查器协议”。我强烈建议您升级到更新版本的Node。目前v8是最新的LTS版本:Node.js releases
https://stackoverflow.com/questions/52640390
复制相似问题