Skip to content
Skills Library
Programming · Building & coding

electronup-build

/electronup-build

运行 electronup dev / electronup build,为 Windows、macOS、Linux 打包指定架构的安装包,只构建渲染进程(--web)或只出目录(--dir),并排查构建/打包失败。用户要启动 Electron 开发环境、打包、出安装包、在 CI 构建或遇到 electronup 构建报错时使用。

Repository
electronup ↗
Licence
MIT
Last repository change
27.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
2
Deprecation

No signals detected. Repository changed on 27.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

运行 electronup dev / electronup build,为 Windows、macOS、Linux 打包指定架构的安装包,只构建渲染进程(--web)或只出目录(--dir),并排查构建/打包失败。用户要启动 Electron 开发环境、打包、出安装包、在 CI 构建或遇到 electronup 构建报错时使用。

Original author description

运行 electronup dev / electronup build,为 Windows、macOS、Linux 打包指定架构的安装包,只构建渲染进程(--web)或只出目录(--dir),并排查构建/打包失败。用户要启动 Electron 开发环境、打包、出安装包、在 CI 构建或遇到 electronup 构建报错时使用。

How it works

  1. 开发:electronup dev
  2. 构建:electronup build
  3. 产物
  4. 推荐验证顺序
  5. 排查
  6. CI 示例(GitHub Actions 矩阵)
Original SKILL.md headings · 91 lines, 458 words
SKILL.md preview
---
name: electronup-build
description: 运行 electronup dev / electronup build,为 Windows、macOS、Linux 打包指定架构的安装包,只构建渲染进程(--web)或只出目录(--dir),并排查构建/打包失败。用户要启动 Electron 开发环境、打包、出安装包、在 CI 构建或遇到 electronup 构建报错时使用。
---

# 用 electronup 开发与打包

在应用项目里优先通过 `package.json` 脚本或 `pnpm exec electronup …`(npm 用 `npx`)运行,使用项目锁定的 electronup 版本。不确定参数时先跑 `electronup --help` / `electronup build --help`,以所装版本输出为准。

## 开发:`electronup dev`

```bash
electronup                    # 等同 electronup dev
electronup dev -p 3000        # 渲染进程起始端口,默认 8090;占用会自动后移
electronup dev -m staging     # 加载 .env + .env.staging
electronup build --no-minify  # 产物不压缩,便于排查(dev 本身不压缩且带 sourcemap)
electronup dev build/electronup.config.ts   # 指定配置文件
```

- 启动时清空 `resourceDir`,起 Vite dev server,watch 构建 preload(修改后重启 Electron),watch 主进程并在每次构建成功后(重)启动 Electron;关闭窗口后命令退出。
- 实际端口通过 `RENDER_PORT` 注入主进程。端口必须是 1–65535 的整数,否则报错退出。
- 本机没有 Electron 二进制(`node_modules/electron/dist`)时拉不起窗口,此时用 `build --dir` 验证。

## 构建:`electronup build`

| 目的 | 命令 |
| --- | --- |
| 当前平台 + 当前架构的安装包 | `electronup build` |
| 只出可运行目录(如 `win-unpacked`),最快的打包验证 | `electronup build --dir` |
| 只构建渲染进程静态资源,不打主进程/preload/安装包 | `electronup build --web` |
| Windows(不写架构 = ia32 + x64 两个包) | `electronup build --win` / `--win x64` / `--win x64 --win arm64` |
| macOS(不写架构 = 当前架构) | `electronup build --mac` / `--mac arm64` / `--mac universal` |
| Linux(不写架构 = 当前架构) | `electronup build --linux` / `--linux x64` / `--linux armv7l` |
| 关闭 asar | `electronup build --no-asar` |
| 其他环境变量文件 | `electronup build -m staging` |
| 交互式向导(仅 TTY) | `electronup build -o` |

规则:

- 合法架构:win `ia32|x64|arm64`,mac `x64|arm64|universal`,linux `x64|arm64|armv7l`;其他值报错退出,不会回退 x64。
- **一次只构建一个平台**;同时传多个平台按 `--win` > `--mac` > `--linux` 取最高者。多平台请分多次执行(CI 里用矩阵)。
- 宿主限制:mac 包只能在 macOS 上构建;Windows 上不能构建 Linux 包;Linux 上 `--win` 不拦截但通常需要 Wine 等工具链。
- `-o` 会接管平台/架构/压缩/`--dir`,不与 `--win` 等叠加;在 CI、IDE 任务等非 TTY 环境会直接退出(码 1),**agent 不要用 `-o`**,改用显式参数。
- build 会先清空 `resourceDir` 和 `outDir`(`--web` 只清 `resourceDir`),清理发生在配置执行与目标校验之后,参数错误时上次产物保持不变。

## 产物

| 路径 | 内容 |
| --- | --- |
| `dist/resource/` | `index.html` 等渲染产物、`electron.cjs`(主进程)、`preload*.cjs` |
| `dist/out/` | 安装包、`*-unpacked` 目录(Windows x64 为 `dist/out/win-unpacked`,ia32 为 `win-ia32-unpacked`;macOS 为 `mac` / `mac-arm64`;Linux 为 `linux-unpacked`)、更新元数据(`latest*.yml`)、`electronup-effective-config.yaml` |

`electronup-effective-config.yaml` 是本次实际生效的合并配置快照(`--web` 不生成),排查“配置有没有生效”先看它。

## 推荐验证顺序

1. `electronup build --web`:渲染进程能否构建。
2. `electronup build --dir`:主进程、preload 与 electron-builder 是否正常,运行 `*-unpacked` 里的可执行文件做冒烟。
3. 目标平台安装包:`electronup build --win x64` 等。

## 排查

| 报错 / 现象 | 处理 |
| --- | --- |
| 下载 electron 压缩包超时 / 失败 | 设置镜像:`ELECTRON_MIRROR=https://cdn.npmmirror.com/binaries/electron/`,`ELECTRON_CUSTOM_DIR={{ version }}` |
| 找不到主进程入口 | 入口必须是 `${mainDir}/index.{ts,mts,cts,js,mjs,cjs}` 之一 |
| 拒绝清空目录 | `resourceDir` / `outDir` 指向了项目根、主目录、`node_modules`、`.git` 或符号链接,改成项目内专用输出目录 |
| 清空时报占用 | 关闭仍在运行的打包应用或占用 `dist` 的进程后重试 |
| Linux 构建要求 snapcraft | electron-builder 默认 Linux 目标含 snap,配置 `builderConfig.linux.target: ['AppImage']`(或 deb/rpm) |
| 打包后启动白屏 / 找不到模块 | 见 `electronup-config` skill 的“常见不生效” |
| `--no-asar` 未传却想关闭 asar | 在 `builderConfig.asar: false` 设置 |

## CI 示例(GitHub Actions 矩阵)

```yaml
strategy:
  matrix:
    include:
      - { os: windows-latest, args: --win x64 }
      - { os: macos-latest, args: --mac }
      - { os: ubuntu-latest, args: --linux x64 }
runs-on: ${{ matrix.os }}
steps:
  - uses: actions/checkout@v4
  - uses: pnpm/action-setup@v4
  - uses: actions/setup-node@v4
    with: { node-version: 24, cache: pnpm }
  - run: pnpm install --frozen-lockfile
  - run: pnpm exec electronup build ${{ matrix.args }}
```

签名证书等通过 CI secrets 以环境变量注入(`CSC_LINK`、`CSC_KEY_PASSWORD`、`APPLE_*`),见 `electronup-config` 的签名一节。

详细文档:<https://quiteerjs.github.io/electronup/introduce/cli>。

Versions

The database has no other skills named electronup-build.

Database snapshot: 13.11.2026 · package version 32a6937404b0 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100electronup-create
    用 create-electronup 新建 electronup + Electron 项目,或把 electronup 接入已有项目。用户提到创建/初始化 Electron 项目、create-electronup、electronup 模板(vanilla/vue/react/react-swc/solid)或“给现有项目加 electronup”时使用。
  • 100electronup-release
    为 electronup 或 create-electronup 准备一次 npm 发布(选版本、升版、验收、changelog、合入 main、打标签、校验 tarball),最后由用户执行 pnpm publish。维护者要发版、升版本号、生成 CHANGELOG 或打 release 标签时使用。
  • 100electron-desktop
    Desktop application development with Electron for Windows, macOS, and Linux. Use when building cross-platform desktop apps, implementing native OS features, or packaging web apps for desktop.
  • 100electron
    Assists with building cross-platform desktop applications using Electron. Use when architecting main/renderer process communication, configuring secure contexts, implementing auto-updates, or packaging apps for Windows, macOS, and Linux. Trigger words: electron, desktop app,…
  • 95electron-crossplatform-performance
    Production architecture, multi-process IPC security, V8 memory management, native node modules, window lifecycle optimization, and cross-platform desktop execution using Electron. Use when building, hardening, or tuning performance for enterprise Electron apps across Windows, macOS, and Linux.
  • 98integration-tests
    Use when running integration tests in the VS Code repo. Covers scripts/test-integration.sh (macOS/Linux) and scripts/test-integration.bat (Windows), their supported arguments for filtering, and the difference between node.js integration tests and extension host tests.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.