gpt4 book ai didi

javascript - 使用 VSCode 调试 electron-forge 应用程序

转载 作者:搜寻专家 更新时间:2023-10-31 23:03:31 26 4
gpt4 key购买 nike

我正在尝试使用 VSCode( Electron 主进程,而不是渲染)调试我的 electron-forge 项目,但到处都是错误。我安装了electron-forge打包所有依赖项并初始化我的项目。

我关注了this指导和我的launch.json对于 VSCode 是:

{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Electron Main",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron-forge-vscode-win.cmd",
"cwd": "${workspaceRoot}"
}
]
}

但是当我点击 F5在 VSCode 中进行调试,我得到了 Attribute "runtimeExecutable" does not exist因为electron-forge已全局安装,因此 node_modules/.bin/ 中没有此类文件目录。

然后根据this我改了"runtimeExecutable"和我的 launch.json如下:

{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Electron Main",
"runtimeExecutable": "electron-forge-vscode-win.cmd",
"cwd": "${workspaceRoot}"
}
]
}

命令行是:

electron-forge-vscode-win.cmd --debug-brk=17423 --nolazy 
√ Locating Application
√ Preparing native dependencies
√ Launching Application

但仍然没有任何反应。我的 Electron 应用程序启动但没有停止为 --debug-brk假设的论点。

接下来,我在 launch.json 中添加了一行:

{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"cwd": "${workspaceRoot}",
"name": "Electron Main",
"runtimeExecutable": "electron-forge-vscode-win.cmd",
"protocol": "inspector"
}
]
}

使用此命令行启动:

electron-forge-vscode-win.cmd --inspect=11172 --debug-brk 
√ Locating Application
√ Preparing native dependencies
√ Launching Application

注意: 11172 是随机端口号

现在我收到这个错误:Cannot connect to runtime process, timeout after 10000 ms - (reason: Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:11172) .

最佳答案

我相信你需要添加"协议(protocol)"="旧版"到您的启动配置。这是假设您使用的是 Node 版本 < 8.x

关于javascript - 使用 VSCode 调试 electron-forge 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44967814/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com