File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 1
1
// @ts -check
2
2
3
+ const minimumNodeVersion = "20.11.0" ;
4
+
3
5
/**
4
6
* @typedef {import("@rescript/linux-x64") } BinaryModuleExports
5
7
*/
@@ -23,6 +25,9 @@ if (supportedPlatforms.includes(target)) {
23
25
try {
24
26
mod = await import ( binPackageName ) ;
25
27
} catch {
28
+ // First check if we are on an unsupported node version, as that may be the cause for the error.
29
+ checkNodeVersionSupported ( ) ;
30
+
26
31
throw new Error (
27
32
`Package ${ binPackageName } not found. Make sure the rescript package is installed correctly.` ,
28
33
) ;
@@ -43,3 +48,26 @@ export const {
43
48
rescript_exe,
44
49
} ,
45
50
} = mod ;
51
+
52
+ function checkNodeVersionSupported ( ) {
53
+ if (
54
+ typeof process !== "undefined" &&
55
+ process . versions != null &&
56
+ process . versions . node != null
57
+ ) {
58
+ const currentVersion = process . versions . node ;
59
+ const required = minimumNodeVersion . split ( "." ) . map ( Number ) ;
60
+ const current = currentVersion . split ( "." ) . map ( Number ) ;
61
+ if (
62
+ current [ 0 ] < required [ 0 ] ||
63
+ ( current [ 0 ] === required [ 0 ] && current [ 1 ] < required [ 1 ] ) ||
64
+ ( current [ 0 ] === required [ 0 ] &&
65
+ current [ 1 ] === required [ 1 ] &&
66
+ current [ 2 ] < required [ 2 ] )
67
+ ) {
68
+ throw new Error (
69
+ `ReScript requires Node.js >=${ minimumNodeVersion } , but found ${ currentVersion } .` ,
70
+ ) ;
71
+ }
72
+ }
73
+ }
You can’t perform that action at this time.
0 commit comments