@electron/devtron

中文文档
2.1.1发布于 2025/11/18MITTypeScriptESM + CJS构建来源已验证近 30 天下载 4106

Electron DevTools Extension to track IPC events

原始使用文档
文档目录6 节
  1. Building and Development
  2. Configuring an Electron App to use Devtron
  3. Devtron API
  4. await devtron.install(options)
  5. await devtron.getEvents()
  6. Requirements and Limitations

Devtron icon Devtron

Test npm version

[!NOTE] This project is under development and subject to change.

Building and Development

This project uses Yarn 4 to manage dependencies.

To get started:

  • Clone the repository to your local machine
  • Run yarn install to install dependencies
  • Run yarn build to build the project

Configuring an Electron App to use Devtron

  • In your Electron app's main entry point, add the following code to load Devtron:
// main.js
const { devtron } = require('@electron/devtron');
// or import { devtron } from '@electron/devtron'

devtron.install(); // call this function at the top of your file
  • Devtron can be conditionally installed in development mode to avoid impacting production builds. Here's an example:
const { app } = require('electron');

const isDev = !app.isPackaged;

async function installDevtron() {
  const { devtron } = await import('@electron/devtron');
  await devtron.install();
}

if (isDev) {
  installDevtron().catch((error) => {
    console.error('Failed to install Devtron:', error);
  });
}

Devtron API

await devtron.install(options)

Installs Devtron into the Electron app. Refer to Configuring an Electron App to use Devtron for installation instructions.

Options

OptionTypeDefaultDescription
logLevel'debug' | 'info' | 'warn' | 'error' | 'none''warn'Sets the minimum log level for the logger. Messages below this level are ignored.

Levels:
• debug — logs: debug, info, warn, error
• info — logs: info, warn, error
• warn — logs: warn, error
• error — logs: error only
• none — disables all logging

Examples:

// Only 'warn' and 'error' logs will appear in the terminal
await devtron.install({ logLevel: 'warn' });

await devtron.getEvents()

Returns a Promise that resolves to the array of IPC events recorded by the Devtron service worker since installation.

  • If the Clear all events button in the Devtron UI is clicked, this array will be cleared.

  • If the array size exceeds 20,000 events, it will be truncated to the most recent 20,000 events.

  • If called before installation or before the Devtron service worker is ready, an empty array will be returned.

Here's a usage example that keeps logging IPC events every 2 seconds:

// main.js
import { devtron } from '@electron/devtron';

// Ensure Devtron is installed before calling getEvents()
devtron.install();

setInterval(async () => {
  const ipcEvents = await devtron.getEvents();
  console.log('IPC Events:', ipcEvents);
}, 2000);

Requirements and Limitations

  • Electron version must be 36.0.0 or higher.
  • For Devtron to work with newly created sessions, you must call devtron.install() before they are created.
  • Some IPC events sent immediately after the Electron app starts may not be captured by Devtron, even if devtron.install() is called early, because Devtron may take a short time to initialize after starting the app.
  • ipcRenderer.once will be tracked as two separate events: ipcRenderer.on and ipcRenderer.removeListener.

If Devtron is installed correctly, it should appear as a tab in the Developer Tools of your Electron app.

版本与发布记录

@electron/devtron 共发布 4 个版本,首次发布于 2025/09/04;过去 12 个月发布了 1 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.1.1latest2025/11/1811 个月前
2.1.02025/09/051.2 年前
2.0.02025/09/041.2 年前
0.0.02025/09/041.2 年前

关于 @electron/devtron 的常见问题

@electron/devtron 是什么?

Electron DevTools Extension to track IPC events

如何安装 @electron/devtron?

在项目目录运行 npm install @electron/devtron,或使用 pnpm add / yarn add / bun add。

@electron/devtron 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@electron/devtron 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@electron/devtron 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.12.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@electron/devtron 可以商用吗?

@electron/devtron 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@electron/devtron 的下载量有多少?

根据 npm 官方下载统计,@electron/devtron 在 2026/10/14 – 2026/11/12 这 30 天内被下载 4,106 次,日均约 137 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@electron/devtron 还在维护吗?

最新版本 2.1.1 发布于 2025/11/18(11 个月前);至今共发布 4 个版本,其中过去 12 个月发布了 1 个;首次发布于 2025/09/04。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。