Skip to content

Commit 0ef6e04

Browse files
joaocgreiscodebytere
authored andcommitted
win: allow skipping the supported platform check
Fixes: #33034 PR-URL: #33176 Reviewed-By: Bartosz Sosnowski <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent 0b34c4f commit 0ef6e04

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

doc/api/cli.md

+9
Original file line numberDiff line numberDiff line change
@@ -1345,6 +1345,15 @@ added:
13451345
Path to a Node.js module which will be loaded in place of the built-in REPL.
13461346
Overriding this value to an empty string (`''`) will use the built-in REPL.
13471347

1348+
### `NODE_SKIP_PLATFORM_CHECK=value`
1349+
<!-- YAML
1350+
added: REPLACEME
1351+
-->
1352+
1353+
If `value` equals `'1'`, the check for a supported platform is skipped during
1354+
Node.js startup. Node.js might not execute correctly. Any issues encountered
1355+
on unsupported platforms will not be fixed.
1356+
13481357
### `NODE_TLS_REJECT_UNAUTHORIZED=value`
13491358

13501359
If `value` equals `'0'`, certificate validation is disabled for TLS connections.

doc/node.1

+7
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,13 @@ The default path is
565565
which is overridden by this variable.
566566
Setting the value to an empty string ("" or " ") will disable persistent REPL history.
567567
.
568+
.It Ev NODE_SKIP_PLATFORM_CHECK
569+
When set to
570+
.Ar 1 ,
571+
the check for a supported platform is skipped during Node.js startup.
572+
Node.js might not execute correctly.
573+
Any issues encountered on unsupported platforms will not be fixed.
574+
.
568575
.It Ev NODE_TLS_REJECT_UNAUTHORIZED
569576
When set to
570577
.Ar 0 ,

src/node_main.cc

+15-3
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,25 @@
2727
#include <VersionHelpers.h>
2828
#include <WinError.h>
2929

30+
#define SKIP_CHECK_VAR "NODE_SKIP_PLATFORM_CHECK"
31+
#define SKIP_CHECK_SIZE 1
32+
#define SKIP_CHECK_VALUE "1"
33+
3034
int wmain(int argc, wchar_t* wargv[]) {
3135
// Windows Server 2012 (not R2) is supported until 10/10/2023, so we allow it
3236
// to run in the experimental support tier.
37+
char buf[SKIP_CHECK_SIZE + 1];
3338
if (!IsWindows8Point1OrGreater() &&
34-
!(IsWindowsServer() && IsWindows8OrGreater())) {
35-
fprintf(stderr, "This application is only supported on Windows 8.1, "
36-
"Windows Server 2012 R2, or higher.");
39+
!(IsWindowsServer() && IsWindows8OrGreater()) &&
40+
(GetEnvironmentVariableA(SKIP_CHECK_VAR, buf, sizeof(buf)) !=
41+
SKIP_CHECK_SIZE ||
42+
strncmp(buf, SKIP_CHECK_VALUE, SKIP_CHECK_SIZE + 1) != 0)) {
43+
fprintf(stderr, "Node.js is only supported on Windows 8.1, Windows "
44+
"Server 2012 R2, or higher.\n"
45+
"Setting the " SKIP_CHECK_VAR " environment variable "
46+
"to 1 skips this\ncheck, but Node.js might not execute "
47+
"correctly. Any issues encountered on\nunsupported "
48+
"platforms will not be fixed.");
3749
exit(ERROR_EXE_MACHINE_TYPE_MISMATCH);
3850
}
3951

0 commit comments

Comments
 (0)