From 33d4b39eb92d51be795f19ee13878fec897a7ff6 Mon Sep 17 00:00:00 2001 From: AskaEth Date: Wed, 9 Sep 2026 21:35:21 +0800 Subject: [PATCH] =?UTF-8?q?fix(build):=20pnpm=2011=20=E7=94=A8=20allowBuil?= =?UTF-8?q?ds=20=E6=94=BE=E8=A1=8C=20electron=20=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pnpm 11 起 onlyBuiltDependencies 列表形式被静默忽略,导致 ERR_PNPM_IGNORED_BUILDS 让 pnpm run 的依赖校验直接失败(pnpm run dist 都起不来)。 改为 pnpm 自己写入的 allowBuilds 映射形式,并去掉 build.bat 里的 --ignore-scripts。 另外修复 set VAR=value && ... 的尾随空格:它会把 ELECTRON_MIRROR 变成 '.../electron/ v38.8.6/...' 从而 404。 --- console/pnpm-workspace.yaml | 11 ++++++++--- deploy/build.bat | 7 +++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/console/pnpm-workspace.yaml b/console/pnpm-workspace.yaml index e348897..bbcd2f8 100644 --- a/console/pnpm-workspace.yaml +++ b/console/pnpm-workspace.yaml @@ -1,5 +1,10 @@ -onlyBuiltDependencies: - - electron - - electron-winstaller +# pnpm 11 把「允许运行安装脚本的依赖」改名为 allowBuilds(列表形式的 +# onlyBuiltDependencies 会被静默忽略,导致 ERR_PNPM_IGNORED_BUILDS 让 pnpm run 直接失败)。 +allowBuilds: + electron: true + electron-winstaller: true overrides: + # app-builder-lib@26.15.3 声明的是 ^3.0.0,但它 import 的 ElectronDownloadCacheMode + # 只有 3.1.0 才导出,不钉死会在 pnpm run dist 时抛 + # TypeError: Cannot read properties of undefined (reading 'ReadWrite')。 "@electron/get": 3.1.0 diff --git a/deploy/build.bat b/deploy/build.bat index fc6d22b..e6a7722 100644 --- a/deploy/build.bat +++ b/deploy/build.bat @@ -52,7 +52,10 @@ node deploy\prepare-extra.mjs || exit /b 1 cd console REM pnpm 11 blocks postinstall by default (ERR_PNPM_IGNORED_BUILDS), so the electron REM runtime binary is fetched explicitly below instead of relying on the install script. -call pnpm install --frozen-lockfile --ignore-scripts || exit /b 1 +REM console\pnpm-workspace.yaml 里的 allowBuilds 已经放行 electron 的安装脚本, +REM 因此这里不再加 --ignore-scripts(否则 pnpm run 的依赖校验会以 +REM ERR_PNPM_IGNORED_BUILDS 失败)。 +call pnpm install --frozen-lockfile || exit /b 1 call :ensure_electron || exit /b 1 call pnpm run dist || exit /b 1 cd .. @@ -65,7 +68,7 @@ dir /b dist\console endlocal exit /b 0 -REM ---- ensure the electron runtime binary is present (pnpm skips its postinstall) -- +REM ---- ensure the electron runtime binary is present (fallback for mirror failures) -- :ensure_electron REM path.txt tells the electron package where the binary is; without it REM electron-builder tries to download the runtime and hits a Node 24 bug.