Skip to content

Commit 6f34a98

Browse files
thomasballingerConvex, Inc.
authored andcommitted
Better errors for zshy Node.js version requirement (#41405)
GitOrigin-RevId: b4e240c570138c377385807e289c2c696dd877a0
1 parent 888e6d5 commit 6f34a98

File tree

6 files changed

+51
-3
lines changed

6 files changed

+51
-3
lines changed

npm-packages/@convex-dev/codemod/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
}
1616
},
1717
"scripts": {
18-
"build": "zshy",
18+
"build": "node version-check.mjs && zshy",
1919
"test": "vitest",
2020
"typecheck": "tsc --noEmit",
2121
"prepublishOnly": "npm run build"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env node
2+
// Until https://github.com/colinhacks/zshy/issues/34 is resolved show a nicer error for the wrong Node.js version
3+
4+
const v = process.versions.node;
5+
const [maj, min, pat] = v.split(".").map(Number);
6+
7+
if (
8+
maj < 20 ||
9+
(maj === 20 && min < 19) ||
10+
(maj === 22 && (min < 12 || (min === 12 && pat < 0)))
11+
) {
12+
console.error(
13+
`Node.js ${v} does not support synchronous require() of ESM. Need 20.19.0+, 22.12.0+, or 23+`,
14+
);
15+
process.exit(1);
16+
}

npm-packages/@convex-dev/platform/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"description": "",
66
"type": "module",
77
"scripts": {
8-
"build": "npm run generateApiSpec && zshy",
8+
"build": "npm run generateApiSpec && node version-check.mjs && zshy",
99
"prepack": "node -e \"if (process.env.npm_config_user_agent && !process.env.npm_config_user_agent.startsWith('pnpm')) { console.error('❌ Use pnpm publish instead of npm publish'); process.exit(1); }\"",
1010
"test": "echo 0",
1111
"typecheck": "tsc --noEmit",
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env node
2+
// Until https://github.com/colinhacks/zshy/issues/34 is resolved show a nicer error for the wrong Node.js version
3+
4+
const v = process.versions.node;
5+
const [maj, min, pat] = v.split(".").map(Number);
6+
7+
if (
8+
maj < 20 ||
9+
(maj === 20 && min < 19) ||
10+
(maj === 22 && (min < 12 || (min === 12 && pat < 0)))
11+
) {
12+
console.error(
13+
`Node.js ${v} does not support synchronous require() of ESM. Need 20.19.0+, 22.12.0+, or 23+`,
14+
);
15+
process.exit(1);
16+
}

npm-packages/@convex-dev/workos/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Helper for authenticating a Convex client via WorkOS AuthKit",
55
"type": "module",
66
"scripts": {
7-
"build": "zshy",
7+
"build": "node version-check.mjs && zshy",
88
"test": "vitest run",
99
"typecheck": "tsc --noEmit"
1010
},
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env node
2+
// Until https://github.com/colinhacks/zshy/issues/34 is resolved show a nicer error for the wrong Node.js version
3+
4+
const v = process.versions.node;
5+
const [maj, min, pat] = v.split(".").map(Number);
6+
7+
if (
8+
maj < 20 ||
9+
(maj === 20 && min < 19) ||
10+
(maj === 22 && (min < 12 || (min === 12 && pat < 0)))
11+
) {
12+
console.error(
13+
`Node.js ${v} does not support synchronous require() of ESM. Need 20.19.0+, 22.12.0+, or 23+`,
14+
);
15+
process.exit(1);
16+
}

0 commit comments

Comments
 (0)