Last Updated: January 28, 2019
·
6.487K
· gwwfps

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');
}

2 Responses
Add your response

thank you!

over 1 year ago ·

Dittos; this saved me some time.

over 1 year ago ·