feat: Add Node version check and .nvmrc
Co-authored-by: mathieumoran1 <[email protected]>
This commit is contained in:
co-authored by
mathieumoran1
parent
6108c8a40f
commit
5abe54be6e
@@ -6,6 +6,9 @@ Would probably need to revamp everything, but didn't want to spend more time on
|
||||

|
||||
|
||||
## 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")<br>
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user