Detecting 64-bit Windows in node.js
Recently, I found myself needing to determine whether a node.js application is running on 64-bit Windows. If your node runtime is 64-bit, then it's all quite straight forward, process.arch will be x64. My particular case, however, is a node-webkit application, using the pre-built binary, which is 32-bit, so it runs through WoW64 and process.arch is ia32.
The way to tell in this case is through the environment variable PROCESSOR_ARCHITEW6432 (accessible through process.env), which will be AMD64 when the process is running in WoW64 on a 64-bit Windows installation, and absent otherwise. Basically, in code, you'd go with something like
function isOSWin64() {
return process.arch === 'x64' || process.env.hasOwnProperty('PROCESSOR_ARCHITEW6432');
}Written by David Zitao Zhang
Related protips
2 Responses
thank you!
Dittos; this saved me some time.
Have a fresh tip? Share with Coderwall community!
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside