Skip to content

[错误]: node-v22.2.0 编译会报错 #8786

@Hiram-Wong

Description

@Hiram-Wong

提交前检查

  • 我理解 Issue 是用于反馈和解决问题的,而非吐槽评论区,将尽可能提供更多信息帮助问题解决。
  • 我的问题不是 常见问题 中的内容。
  • 我已经查看了 置顶 Issue 并搜索了现有的 开放Issue已关闭Issue,没有找到类似的问题。
  • 我填写了简短且清晰明确的标题,以便开发者在翻阅 Issue 列表时能快速确定大致问题。而不是“一个建议”、“卡住了”等。

平台

macOS

版本

1.5.4-rc.2

错误描述

编译报错

Image

重现步骤

  1. yarn
  2. yarn build:npm
  3. yarn build:mac

预期行为

希望兼容 node 22.2 版本

相关日志输出

✓ built in 6.67s
  • electron-builder  version=26.0.15 os=25.0.0
  • loaded configuration  file=/Users/HiramWong/Data/code/cherry-studio/electron-builder.yml
  • writing effective config  file=dist/builder-effective-config.yaml
  • executing @electron/rebuild  electronVersion=37.2.3 arch=x64 buildFromSource=false appDir=./
  • installing native dependencies  arch=x64
  ⨯ /Users/HiramWong/Data/code/cherry-studio/node_modules/@electron/rebuild/lib/rebuild.js:33
const nodeAbi = __importStar(require("node-abi"));
                             ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/HiramWong/Data/code/cherry-studio/node_modules/node-abi/index.js from /Users/HiramWong/Data/code/cherry-studio/node_modules/@electron/rebuild/lib/rebuild.js not supported.
Instead change the require of index.js in /Users/HiramWong/Data/code/cherry-studio/node_modules/@electron/rebuild/lib/rebuild.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/Users/HiramWong/Data/code/cherry-studio/node_modules/@electron/rebuild/lib/rebuild.js:33:30) {
  code: 'ERR_REQUIRE_ESM'
}

Node.js v22.2.0

  ⨯ Rebuilder failed with exit code: 1  failedTask=build stackTrace=Error: Rebuilder failed with exit code: 1
    at ChildProcess.<anonymous> (/Users/HiramWong/Data/code/cherry-studio/node_modules/app-builder-lib/src/util/rebuild/rebuild.ts:55:32)
    at ChildProcess.emit (node:events:520:28)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:294:12)

附加信息

node -v -> v22.2.0
yarn -v -> 4.9.1

node 降级为 v22.13.1 正常编译

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions