2015-09-01 02:12:57 +00:00
|
|
|
# Debugging the Main Process
|
2014-08-20 02:01:43 +00:00
|
|
|
|
2016-09-21 09:39:15 +00:00
|
|
|
The DevTools in an Electron browser window can only debug JavaScript that's
|
|
|
|
executed in that window (i.e. the web pages). To debug JavaScript that's
|
|
|
|
executed in the main process you will need to use an external debugger and
|
|
|
|
launch Electron with the `--debug` or `--debug-brk` switch.
|
2014-08-20 02:01:43 +00:00
|
|
|
|
2015-09-01 02:12:57 +00:00
|
|
|
## Command Line Switches
|
|
|
|
|
2016-09-21 09:39:15 +00:00
|
|
|
Use one of the following command line switches to enable debugging of the main
|
|
|
|
process:
|
2014-08-20 02:43:41 +00:00
|
|
|
|
|
|
|
### `--debug=[port]`
|
2014-08-20 02:01:43 +00:00
|
|
|
|
2016-09-21 09:39:15 +00:00
|
|
|
Electron will listen for V8 debugger protocol messages on the specified `port`,
|
|
|
|
an external debugger will need to connect on this port. The default `port` is
|
|
|
|
`5858`.
|
2014-08-20 02:01:43 +00:00
|
|
|
|
2014-08-20 02:53:20 +00:00
|
|
|
### `--debug-brk=[port]`
|
2014-08-20 02:01:43 +00:00
|
|
|
|
2016-09-21 09:39:15 +00:00
|
|
|
Like `--debug` but pauses execution on the first line of JavaScript.
|
2014-08-20 02:43:41 +00:00
|
|
|
|
2016-09-21 09:39:15 +00:00
|
|
|
## External Debuggers
|
2016-09-20 05:43:05 +00:00
|
|
|
|
2016-09-21 09:39:15 +00:00
|
|
|
You will need to use a debugger that supports the V8 debugger protocol,
|
|
|
|
the following guides should help you to get started:
|
2016-09-20 05:43:05 +00:00
|
|
|
|
2016-09-21 09:39:15 +00:00
|
|
|
- [Debugging the Main Process in VSCode](debugging-main-process-vscode.md)
|
|
|
|
- [Debugging the Main Process in node-inspector](debugging-main-process-node-inspector.md)
|