From 5abe54be6e61a0a664af72b08a7b4363e563874c Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 20 Dec 2025 21:58:58 +0000 Subject: [PATCH] feat: Add Node version check and .nvmrc Co-authored-by: mathieumoran1 --- .nvmrc | 1 + README.md | 3 +++ package.json | 4 ++++ scripts/check-node-version.js | 39 +++++++++++++++++++++++++++++++++++ 4 files changed, 47 insertions(+) create mode 100644 .nvmrc create mode 100644 scripts/check-node-version.js diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..2bd5a0a --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +22 diff --git a/README.md b/README.md index 9289469..680203b 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,9 @@ Would probably need to revamp everything, but didn't want to spend more time on ![Oscars Pool 2025](https://github.com/quoije/oscar-pool/blob/prod/img/preview.png) ## Setup +### Node version +Use **Node.js LTS (18/20/22)**. Node 23+ (e.g. Node 25) is currently not supported due to a transitive dependency used by `jsonwebtoken`. + Config those in your .env file: **DOG_NAMES=**`woof, WOOF, Woof`     (for "verification")
diff --git a/package.json b/package.json index 51dc847..024c434 100644 --- a/package.json +++ b/package.json @@ -3,12 +3,16 @@ "version": "1.0.0", "main": "index.js", "scripts": { + "preinstall": "node ./scripts/check-node-version.js", "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC", "description": "", + "engines": { + "node": ">=18 <23" + }, "dependencies": { "axios": "^1.7.9", "bcryptjs": "^2.4.3", diff --git a/scripts/check-node-version.js b/scripts/check-node-version.js new file mode 100644 index 0000000..1b893f0 --- /dev/null +++ b/scripts/check-node-version.js @@ -0,0 +1,39 @@ +/** + * This project currently relies on transitive deps (via jsonwebtoken/jws/jwa) + * that are not yet compatible with Node 23+ (e.g. Node 25 removes SlowBuffer). + * + * Render (and most production platforms) typically run an LTS release (18/20/22). + * If you're using a "Current" Node locally, pin to an LTS to avoid install/runtime issues. + */ +const nodeVersion = process.versions.node || ""; +const major = Number(String(nodeVersion).split(".")[0]); + +if (!Number.isFinite(major)) { + console.error( + `[preinstall] Could not parse Node version: "${nodeVersion}". ` + + "Please use Node 18/20/22 (LTS).", + ); + process.exit(1); +} + +if (major >= 23) { + console.error( + [ + `[preinstall] Unsupported Node.js version detected: v${nodeVersion}`, + "", + "This project currently requires an LTS Node release (18/20/22).", + "Reason: a transitive dependency uses APIs removed/changed in Node 23+", + '(commonly seen as "buffer-equal-constant-time" failing on SlowBuffer).', + "", + "Fix (Windows):", + "- Install/use Node 22 LTS (recommended) or Node 20 LTS", + "- Reinstall deps: delete node_modules + package-lock.json, then `npm install`", + "", + "Fix (macOS/Linux):", + "- `nvm install 22 && nvm use 22` (or `nvm install 20 && nvm use 20`)", + "", + ].join("\n"), + ); + process.exit(1); +} + -- 2.54.0