Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.0k views
in Technique[技术] by (71.8m points)

javascript - How to get Windows version using Node.js?

There are questions about OS version on the Stack Overflow but not about the Windows name, I am looking to find out Windows name using Node.js.

I have looked into so many modules like os, platform, getos and using process etc. and found that these are helpful to get operating system description, process environment etc. I am able to get it is Linux or Windows too i.e. which platform I am using.

But, how can I check, is it Windows 7 or 8 which is installed on my system using Node.js?

I am using kinect2 module in my Node.js project which is working fine on Windows 8 but I am looking to use it on Windows 7.

I have checked that Kinect2 will not work with Windows 7.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Use os.release().

> os.release();
'10.0.18363'

On Windows, the result is in the form major.minor.build

Consult this table (source) to determine the version of Windows:

 Version                                    major.minor   
------------------------------------------ ------------- 
 Windows 10, Windows Server 2016            10.0
 Windows 8.1, Windows Server 2012 R2        6.3
 Windows 8, Windows Server 2012             6.2
 Windows 7, Windows Server 2008 R2          6.1
 Windows Vista, Windows Server 2008         6.0
 Windows XP Professional x64 Edition,       5.2
 Windows Server 2003, Windows Home Server
 Windows XP                                 5.1
 Windows 2000                               5.0

For Windows 10 specifically, consult this table (source) to determine the exact version:

 Version           build
----------------- -------
 Windows 10 1909   18363
 Windows 10 1903   18362
 Windows 10 1809   17763
 Windows 10 1803   17134
 Windows 10 1709   16299
 Windows 10 1703   15063
 Windows 10 1607   14393
 Windows 10 1511   10586
 Windows 10 1507   10240

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...