> For the complete documentation index, see [llms.txt](https://yuzhigang5460.gitbook.io/electron/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yuzhigang5460.gitbook.io/electron/tutorial/debugging-main-process.md).

# 主进程调试

> 浏览器窗口的开发工具仅能调试渲染器的进程脚本（比如 web 页面）。Electron 提供了 `--debug` 和 `--debug-brk` 开关可以调试主进程。

## 命令行开关

使用如下的命令行开关来调试 Electron 的主进程：

### `--debug=[port]`

当这个开关用于 Electron 时，它将会监听 V8 引擎中有关 `port` 的调试器协议信息。默认的 `port` 是 `5858`。

```
electron --debug=5858 your/app
```

### `--debug-brk=[port]`

就像 `--debug` 一样，但是会在第一行暂停脚本运行。

## External Debuggers

如果需要使用一个支持 V8 调试器的调试协议，请参考：

* [使用 VSCode 进行主进程调试](/electron/tutorial/debugging-main-process-vscode.md)
* [使用 node-inspector 进行主进程调试](/electron/tutorial/debugging-main-process-node-inspector.md)
