我試圖用VSCode(電子主進程,不渲染)調試我的電子僞造項目,但隨處可見錯誤。我安裝了具有所有依賴項的electron-forge
包,並初始化我的項目。使用VSCode調試電子僞造應用程序
我跟着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}"
}
]
}
但是,當我在VSCode打F5
調試,我得到Attribute "runtimeExecutable" does not exist
,因爲electron-forge
在全球範圍內安裝,以便有在node_modules/.bin/
dir中沒有這樣的文件。
然後根據this我改變"runtimeExecutable"
和我launch.json
如下:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Electron Main",
"runtimeExecutable": "electron-forge-vscode-win.cmd",
"cwd": "${workspaceRoot}"
}
]
}
的COMAND行是:
electron-forge-vscode-win.cmd --debug-brk=17423 --nolazy
√ Locating Application
√ Preparing native dependencies
√ Launching Application
但仍然沒有發生。我的電子應用程序開始,但並沒有停止,因爲--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
注:是一個隨機端口號
現在我收到此錯誤:Cannot connect to runtime process, timeout after 10000 ms - (reason: Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:11172)
。
顯然這是由電子預編譯(1.8.2-beta 3)使用的電子版本中的一個錯誤。見https://github.com/electron-userland/electron-forge/issues/401#issuecomment-354369382。 –