Debugging

Debugging on the Command Line

If you're using Electron 1.8 or later, you can specify the --inspect-electron flag when running electron-forge start, which will set the Electron --inspectflag with the default debugger port.
1
electron-forge start --inspect-electron
Copied!
This will allow you to open chrome://inspect in Google Chrome and attach a debugger to the main process of your app.

Debugging with VS Code

Debugging your Electron main process through VS Code is ridiculously easy with Forge. Simply add this as a launch config in VSCode and you're good to go.
You need to be using Electron 1.8 or later for this launch config to work.
If you are using < 1.8 you should really be updating Electron anyway.
launch.config
1
{
2
"type": "node",
3
"request": "launch",
4
"name": "Electron Main",
5
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron-forge-vscode-nix",
6
"windows": {
7
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron-forge-vscode-win.cmd"
8
},
9
// runtimeArgs will be passed directly to your Electron application
10
"runtimeArgs": [
11
"foo",
12
"bar"
13
],
14
"cwd": "${workspaceFolder}"
15
}
Copied!
Last modified 3yr ago