@electron/universal

中文文档
3.0.6发布于 2026/07/03MITES Module构建来源已验证近 30 天下载 3549万

Utility for creating Universal macOS applications from two x64 and arm64 Electron applications

原始使用文档
文档目录6 节
  1. Usage
  2. Advanced configuration
  3. Merging ASAR archives to reduce app size
  4. Skip lipo for certain binaries in your Universal app
  5. Including already codesigned app bundles into your Universa…
  6. FAQ

@electron/universal

Create universal macOS Electron applications

Test NPM package API docs

Usage

This package takes an x64 app and an arm64 app and glues them together into a Universal macOS binary.

Note that parameters need to be absolute paths.

import { makeUniversalApp } from '@electron/universal';

await makeUniversalApp({
  x64AppPath: 'path/to/App_x64.app',
  arm64AppPath: 'path/to/App_arm64.app',
  outAppPath: 'path/to/App_universal.app',
});

For full API usage, see the API documentation.

Advanced configuration

The basic usage patterns will work for most apps out of the box. Additional configuration options are available for advanced usecases.

Merging ASAR archives to reduce app size

Added in v1.2.0

If you are using ASAR archives to store your Electron app's JavaScript code, you can use the mergeASARs option to merge your x64 and arm64 ASAR files to reduce the bundle size of the output Universal app.

If some files are present in only the x64 app but not the arm64 version (or vice-versa), you can exclude them from the merging process by specifying a minimatch pattern in singleArchFiles.

import { makeUniversalApp } from '@electron/universal';

await makeUniversalApp({
  x64AppPath: 'path/to/App_x64.app',
  arm64AppPath: 'path/to/App_arm64.app',
  outAppPath: 'path/to/App_universal.app',
  mergeASARs: true,
  singleArchFiles: 'node_modules/some-native-module/lib/binding/Release/**', // if you have files in your asar that are unique to x64 or arm64 apps
});

If @electron/universal detects an architecture-unique file that isn't covered by the singleArchFiles rule, an error will be thrown.

Skip lipo for certain binaries in your Universal app

Added in 1.3.0

If your Electron app contains binary resources that are already merged with the lipo tool, providing a minimatch pattern to matching files in the x64ArchFiles parameter will prevent @electron/universal from attempting to merge them a second time.

import { makeUniversalApp } from '@electron/universal';

await makeUniversalApp({
  x64AppPath: 'path/to/App_x64.app',
  arm64AppPath: 'path/to/App_arm64.app',
  outAppPath: 'path/to/App_universal.app',
  mergeASARs: true,
  x64ArchFiles: '*/electron-helper', // `electron-helper` is a binary merged using `lipo`
});

If @electron/universal detects a lipo'd file that isn't covered by the x64ArchFiles rule, an error will be thrown.

Including already codesigned app bundles into your Universal app

Added in v1.4.0

By default, the merging process will generate an ElectronAsarIntegrity key for any Info.plist files in your Electron app.

If your Electron app bundles another .app that is already signed, you need to use the infoPlistsToIgnore option to avoid modifying that app's plist.

import { makeUniversalApp } from '@electron/universal';

await makeUniversalApp({
  x64AppPath: 'path/to/App_x64.app',
  arm64AppPath: 'path/to/App_arm64.app',
  outAppPath: 'path/to/App_universal.app',
  infoPlistsToIgnore: 'my-internal.app/Contents/Info.plist'
});

FAQ

The app is twice as big now, why?

A Universal app is just the x64 app and the arm64 app glued together into a single application. It's twice as big because it contains two apps in one.

Merging your ASAR bundles can yield significant app size reductions depending on how large your app.asar file is.

What about native modules?

Out of the box, you don't need to worry about building universal versions of your native modules. As long as your x64 and arm64 apps work in isolation, the Universal app will work as well.

Note that if you are using mergeASARs, you may need to add architecture-specific binary resources to the singleArchFiles pattern. See Merging ASARs usage for an example.

版本与发布记录

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

版本发布日期距今
3.0.6latest2026/07/034 个月前
3.0.52026/06/294 个月前
3.0.42026/04/226 个月前
3.0.32026/03/177 个月前
3.0.22025/10/301 年前
3.0.12025/08/011.3 年前

关于 @electron/universal 的常见问题

@electron/universal 是什么?

Utility for creating Universal macOS applications from two x64 and arm64 Electron applications

如何安装 @electron/universal?

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

@electron/universal 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/electron__universal 是否存在。

@electron/universal 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

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

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

@electron/universal 可以商用吗?

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

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

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

@electron/universal 还在维护吗?

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