From 3d422a5e6e1c8b0c4c061f66c4ad21550de2888d Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 10 Aug 2026 23:25:24 +0000 Subject: [PATCH 1/2] feat: fail clearly on unsupported 32-bit build machines --- README.md | 10 ++++++++++ package.json | 4 ++++ script/select-7z-arch.js | 7 ++++++- spec/assert-supported-arch-spec.ts | 12 ++++++++++++ src/index.ts | 15 +++++++++++++++ 5 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 spec/assert-supported-arch-spec.ts diff --git a/README.md b/README.md index a0d9c13e..7fd7cce1 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,16 @@ NPM module that builds Windows installers for npm install --save-dev electron-winstaller ``` +## Supported platforms + +Installers can be created on x64 and arm64 build machines (Windows, or +macOS/Linux with Wine and Mono). 32-bit build machines are not supported — +if you are on 64-bit Windows, make sure you are running 64-bit Node.js. + +Apps targeting 32-bit Windows (Electron <= 43) can still be packaged from +a 64-bit machine; the generated installer runs on 32-bit Windows. Electron +44 and later do not ship 32-bit Windows builds. + ## Usage Require the package: diff --git a/package.json b/package.json index 887508af..b81c28d7 100644 --- a/package.json +++ b/package.json @@ -54,6 +54,10 @@ "engines": { "node": ">=8.0.0" }, + "cpu": [ + "x64", + "arm64" + ], "publishConfig": { "provenance": true }, diff --git a/script/select-7z-arch.js b/script/select-7z-arch.js index 7be25c8c..4d68ada1 100644 --- a/script/select-7z-arch.js +++ b/script/select-7z-arch.js @@ -5,7 +5,12 @@ const os = require('os'); * Even if we're cross-compiling for a different arch like arm64, * we still need to use the 7-Zip executable for the host arch */ -const arch = os.arch; +const arch = os.arch(); + +if (arch !== 'x64' && arch !== 'arm64') { + console.warn('electron-winstaller: 32-bit build machines are not supported; installer creation will fail on this machine.'); + process.exit(0); +} console.log('Selecting 7-Zip for arch ' + arch); diff --git a/spec/assert-supported-arch-spec.ts b/spec/assert-supported-arch-spec.ts new file mode 100644 index 00000000..04e4a5fa --- /dev/null +++ b/spec/assert-supported-arch-spec.ts @@ -0,0 +1,12 @@ +import test from 'ava'; +import { assertSupportedArch } from '../src/index'; + +test('throws for 32-bit architectures', (t): void => { + t.throws(() => assertSupportedArch('ia32'), { message: '32-bit build machines are not supported' }); + t.throws(() => assertSupportedArch('arm'), { message: '32-bit build machines are not supported' }); +}); + +test('does not throw for 64-bit architectures', (t): void => { + t.notThrows(() => assertSupportedArch('x64')); + t.notThrows(() => assertSupportedArch('arm64')); +}); diff --git a/src/index.ts b/src/index.ts index c3148696..30c1d99e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -47,6 +47,19 @@ export function sanitizeAuthors(authors: string): string { return authors.replace(/@/g, ''); } +/** + * Asserts that the host architecture is supported. Installer creation + * requires an x64 or arm64 build machine; the bundled 7-Zip, NuGet, and + * Squirrel tooling cannot run on 32-bit hosts. + * + * @param arch The host architecture, as reported by `process.arch` + */ +export function assertSupportedArch(arch: string = process.arch): void { + if (arch !== 'x64' && arch !== 'arm64') { + throw new Error('32-bit build machines are not supported'); + } +} + function checkIfCommandExists(command: string): Promise { const checkCommand = os.platform() === 'win32' ? 'where' : 'which'; return new Promise((resolve) => { @@ -64,6 +77,8 @@ function checkIfCommandExists(command: string): Promise { * @see {@link https://github.com/Squirrel/Squirrel.Windows | Squirrel.Windows} */ export async function createWindowsInstaller(options: SquirrelWindowsOptions): Promise { + assertSupportedArch(); + let useMono = false; const monoExe = 'mono'; From b6d4879b53e8ab931976185cd6f11ad3f52499cb Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 11 Aug 2026 00:47:12 +0000 Subject: [PATCH 2/2] fix: drop cpu field from package.json Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01SeZVGwhnCwgbxNcio8oiFo --- package.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/package.json b/package.json index b81c28d7..887508af 100644 --- a/package.json +++ b/package.json @@ -54,10 +54,6 @@ "engines": { "node": ">=8.0.0" }, - "cpu": [ - "x64", - "arm64" - ], "publishConfig": { "provenance": true },