I know that I can get the OS details using process.platform or with the os Module, but I'd also like to know if the OS is a 32 or 64 bit flavor.
Is that possible?
It's far easier than that, just use process.arch
. It'll return x64
or x32
depending on the architecture.
I would use process.env['MACHTYPE']
or process.env['HOSTTYPE']
. If either are undefined
, then check with uname -m
(that is supposed to work on all POSIX systems,
though the output can be any string in fact, see uname(1P)).
var exec = require('child_process').exec, arch;
exec('uname -m', function (error, stdout, stderr) {
if (error) throw error;
arch = stdout;
});
Well, may be it's not quite as brief as you wish, however you would probably find a plenty of shell scripts which do just that for whatever system you are running on and you can just run such script instead. That way you will have just one thing to run and check the output of from your Node app.
Another solution would be to write a module for Node in C++ which would check for low-level system features, including the endianess and whatever else one might need to check. There plenty of example on how to check such things.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With