You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Apple Silicon设备执行electron-forge make失败:openfolder不支持

解决Apple Silicon设备上Electron Forge生成DMG时的bless命令错误

环境信息

  • 设备:MacBook Air M2
  • 系统:Sonoma 14.0
  • Electron版本:27.0.3

问题重现

执行electron-forge make生成应用分发包时,DMG制作失败,核心错误如下:

bless: The 'openfolder' is not supported on Apple Silicon devices.

完整错误日志:

✔ Checking your system
✔ Loading configuration
✔ Resolving make targets
  › Making for the following targets: zip, dmg
✔ Running package command
  ✔ Preparing to package application
  ✔ Running packaging hooks
    ✔ Running generateAssets hook
    ✔ Running prePackage hook
      ✔ [plugin-webpack] Preparing native dependencies
      ✔ [plugin-webpack] Building webpack bundles
  ✔ Packaging application
    ✔ Packaging for x64 on darwin [3s]
  ✔ Running postPackage hook
✔ Running preMake hook
❯ Making distributables
  ✔ Making a zip distributable for darwin/x64 [11s]
  ✖ Making a dmg distributable for darwin/x64
    › Command failed: bless --folder /Volumes/ApplicationName --openfolder /Volumes/ApplicationName
      bless: The 'openfolder' is not supported on Apple Silicon devices.
◼ Running postMake hook


An unhandled rejection has occurred inside Forge:
Error: Command failed: bless --folder /Volumes/ApplicationName --openfolder /Volumes/ApplicationName
bless: The 'openfolder' is not supported on Apple Silicon devices.
at makeError (/Users/elerua/Code/CE-mainrepo/Frontend/node_modules/appdmg/node_modules/execa/index.js:174:9)
    at /Users/elerua/Code/CE-mainrepo/Frontend/node_modules/appdmg/node_modules/execa/index.js:278:16
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

当前package.json中的makers配置

"makers": [
    {
        "name": "@electron-forge/maker-squirrel",
        "config": {
            "name": APPLICATION_NAME,
            "setupIcon": APPLICATION_ICON
        }
    },
    {
        "name": "@electron-forge/maker-zip",
        "config": {
            "name": APPLICATION_NAME
        },
        "platforms": [
            "darwin"
        ]
    },
    {
        "name": "@electron-forge/maker-dmg",
        "config": {
            "name": APPLICATION_NAME,
            "setupIcon": APPLICATION_ICON,
            "format": "ULFO"
        }
    },
    {
        "name": "@electron-forge/maker-deb",
        "config": {
            "name": APPLICATION_NAME,
            "setupIcon": APPLICATION_ICON
        }
    },
    {
        "name": "@electron-forge/maker-rpm",
        "config": {
            "name": APPLICATION_NAME,
            "setupIcon": APPLICATION_ICON
        }
    }
]

解决方案

1. 升级@electron-forge/maker-dmg到最新版本

旧版@electron-forge/maker-dmg依赖的appdmg库在Apple Silicon上调用了已废弃的--openfolder参数,新版本已修复该兼容性问题。执行以下命令升级:

npm update @electron-forge/maker-dmg
# 若使用yarn则执行:
yarn upgrade @electron-forge/maker-dmg

2. 禁用DMG自动打开功能

如果升级后仍有问题,可在DMG生成配置中添加openAtMount: false,阻止工具调用带有--openfolder的bless命令:

{
    "name": "@electron-forge/maker-dmg",
    "config": {
        "name": APPLICATION_NAME,
        "setupIcon": APPLICATION_ICON,
        "format": "ULFO",
        "openAtMount": false
    }
}

3. 构建Apple Silicon原生架构包

当前日志显示正在构建x64架构包,在M2设备上建议直接构建arm64原生包,避免架构兼容问题:

  • 执行命令时指定架构:
electron-forge make --arch arm64
  • 或者在makers配置中为DMG指定架构:
{
    "name": "@electron-forge/maker-dmg",
    "config": {
        "name": APPLICATION_NAME,
        "setupIcon": APPLICATION_ICON,
        "format": "ULFO"
    },
    "arch": ["arm64"]
}

内容的提问来源于stack exchange,提问作者Elerua

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.07 03:12:06