Skip to content

Commit b7a7e62

Browse files
authored
Fail fast on unsupported Node versions (#140)
* Fail fast on unsupported Node versions npm install now errors immediately with a clear "Unsupported engine" message on Node <24, instead of silently proceeding and failing later with a confusing Rollup syntax error deep in the Google-Photos-Toolkit submodule build (see #135). * Standardize on Node 22 throughout Both CI jobs, .nvmrc, and package.json engines now agree on Node 22. The test job was already pinned to 22 (Node 24.16.0 hangs installing Playwright's browser, see #123); aligning everything else avoids the same conflict resurfacing elsewhere. * Replace engines field with a preinstall version check package.json's "engines" field broke the extension: Plasmo builds on Parcel, which reads "engines" to infer build targets. With engines.node set, Parcel misidentified the browser bundle's target environment and stopped bundling react/jsx-runtime for the browser, leaving the app tab blank (reproduced locally — all 18 integration tests failed with "Cannot find module 'react/jsx-runtime'" as a pageerror). A preinstall script gives the same fail-fast UX on npm install without package.json ever declaring "engines", so Parcel's target inference is unaffected. Verified: npm ci fails fast on Node <22 (simulated), and the built extension renders correctly on Node 22. Drop .npmrc/engine-strict too — it only existed to enforce our own engines field, which no longer exists.
1 parent 76abecd commit b7a7e62

4 files changed

Lines changed: 13 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ jobs:
9797

9898
- uses: actions/setup-node@v5
9999
with:
100-
node-version: 24
100+
node-version: 22
101101
cache: npm
102102

103103
- name: Install dependencies

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
24
1+
22

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"author": "Mack Talcott",
77
"license": "AGPL-3.0-or-later",
88
"scripts": {
9+
"preinstall": "node tools/check-node-version.js",
910
"build:gptk": "git submodule update --init && (test -d Google-Photos-Toolkit/node_modules || npm --prefix Google-Photos-Toolkit install --no-fund --no-audit) && cd Google-Photos-Toolkit && npm run build && cp google_photos_toolkit.user.js ../scripts/google-photos-toolkit.user.js",
1011
"copy:wasm": "cp node_modules/@mediapipe/tasks-vision/wasm/vision_wasm_internal.js scripts/ && cp node_modules/@mediapipe/tasks-vision/wasm/vision_wasm_internal.wasm scripts/",
1112
"build:worker": "node_modules/.bin/esbuild workers/embedder.worker.ts --bundle --platform=browser --format=iife --target=es2020 --outfile=scripts/embedder-worker.js",

tools/check-node-version.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const required = 22
2+
const actual = parseInt(process.versions.node.split(".")[0], 10)
3+
4+
if (actual < required) {
5+
console.error(
6+
`\nUnsupported Node version: ${process.version} (need >=${required}.x.x)\n` +
7+
`Run 'nvm use' to switch to the version pinned in .nvmrc.\n`
8+
)
9+
process.exit(1)
10+
}

0 commit comments

Comments
 (0)