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!
over 1 year ago
·
Dittos; this saved me some time.
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Nodejs
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#