Skip to content

Commit 0f647e4

Browse files
committed
fix(os): return 'arm64' from os.machine() on Windows ARM64 (fix #62232)
1 parent 8720ac6 commit 0f647e4

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/node_os.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,21 @@ static void GetOSInformation(const FunctionCallbackInfo<Value>& args) {
9191
return;
9292
}
9393

94+
#ifdef _WIN32
95+
// On Windows, uv_os_uname may return "unknown" for the machine field on ARM64.
96+
// Try to detect the processor architecture via Windows APIs.
97+
if (strcmp(info.machine, "unknown") == 0) {
98+
SYSTEM_INFO sys_info;
99+
GetSystemInfo(&sys_info);
100+
101+
// Map Windows processor architecture to machine designations
102+
// PROCESSOR_ARCHITECTURE_ARM64 = 12
103+
if (sys_info.wProcessorArchitecture == 12) {
104+
snprintf(info.machine, sizeof(info.machine), "arm64");
105+
}
106+
}
107+
#endif
108+
94109
// [sysname, version, release, machine]
95110
Local<Value> osInformation[4];
96111
if (String::NewFromUtf8(env->isolate(), info.sysname)

0 commit comments

Comments
 (0)