Node.js to get/determine OS version

you could use the OS module like this:

var os = require('os');
os.platform(); // 'darwin'
os.release(); //'10.8.0'

and then map the release version to a specific version of Mac OS X.

Darwin to Mac OS X mappings can be found here


As mentioned above in AndyD's answer's comments, os.release() returns the kernel version. If you want to get the same version number that a user sees in the "About this Mac" UI, you can read and parse out /System/Library/CoreServices/SystemVersion.plist, like so:

const plist = require('plist');
let versionInfo = plist.parseFileSync('/System/Library/CoreServices/SystemVersion.plist');
console.log(JSON.stringify(versionInfo));

https://github.com/kevinsawicki/node-plist