【发布时间】:2021-07-03 15:52:10
【问题描述】:
我正在尝试在 vs 代码中调试电子应用程序(主进程,而不是渲染器进程)。我正在尝试调试的项目是这个 repo:
https://github.com/hello-efficiency-inc/raven-reader
一旦你克隆了它并安装了正确的东西,它就真的很好用。然后我就可以运行了:
yarn electron:serve
而且,它运行良好。 但我也想调试这个。于是我环顾了一下,发现我大概应该使用.vscode目录下的这个launch.json文件:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Electron: Main",
"protocol": "inspector",
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
"runtimeArgs": ["--remote-debugging-port=9223", "."],
"windows": {
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd"
}
}
]
}
在我的 package.json 中,我有这一行用于查找 startfile:
"main": "./src/background.js",
所以,我尝试通过单击调试图标来运行,然后单击它显示的绿色三角形
run and debug | Electron:Main
这在调用堆栈菜单中给了我这个:
但实际上似乎没有任何东西在运行,我没有看到任何我想要的桌面窗口,因此我可以实际调试,而且我也无法命中断点
【问题讨论】:
-
设置断点时会发生什么。是活跃的吗?顶层可能会崩溃吗?
标签: node.js visual-studio-code electron