有没有办法知道什么Windows版本在NodeJS中运行?

我有一个场景,我需要知道如果我正在运行Windows 8.1(而不是任何其他Windows版本),使用节点JS。 有没有办法找出这些信息?

提前致谢。

你可以使用os模块:

 var os = require('os'); os.platform(); os.release(); 

对于Windows os.platform()返回win32 ,所以你可以使用:

 if (os.platform() === 'win32') { console.log(os.release()); }