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
|
2017-06-06 21:30:45 +00:00
|
|
|
launch Electron with the `--inspect` or `--inspect-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
|
|
|
|
2017-05-15 16:34:55 +00:00
|
|
|
### `--inspect=[port]`
|
2014-08-20 02:01:43 +00:00
|
|
|
|
2017-05-15 16:34:55 +00:00
|
|
|
Electron will listen for V8 inspector protocol messages on the specified `port`,
|
2016-09-21 09:39:15 +00:00
|
|
|
an external debugger will need to connect on this port. The default `port` is
|
|
|
|
`5858`.
|
2014-08-20 02:01:43 +00:00
|
|
|
|
2016-10-31 16:27:42 +00:00
|
|
|
```shell
|
2017-05-15 16:34:55 +00:00
|
|
|
electron --inspect=5858 your/app
|
2016-10-28 15:04:51 +00:00
|
|
|
```
|
2016-10-31 16:27:42 +00:00
|
|
|
|
2017-05-15 16:34:55 +00:00
|
|
|
### `--inspect-brk=[port]`
|
2014-08-20 02:01:43 +00:00
|
|
|
|
2017-11-06 00:23:18 +00:00
|
|
|
Like `--inspect` 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
|
|
|
|
2017-05-15 16:34:55 +00:00
|
|
|
You will need to use a debugger that supports the V8 inspector protocol.
|
2016-09-20 05:43:05 +00:00
|
|
|
|
2017-05-15 16:40:00 +00:00
|
|
|
- Connect Chrome by visiting `chrome://inspect` and selecting to inspect the
|
|
|
|
launched Electron app present there.
|
2020-11-07 00:55:55 +00:00
|
|
|
- [Debugging in VSCode](debugging-vscode.md)
|