Node.js | os.version() Method

The os.version() method is used to identify the version of the kernel of the Operating System. This information is determined by calling uname on POSIX systems and calling RtlGetVersion() or GetVersionExW() on Windows systems.

Syntax:

os.version()

Parameters: This function does not accept any parameters.

Return Value: It returns a string that identifies the kernel version.

Below programs illustrate the os.version() method in Node.js:



Example 1: On POSIX

filter_none

edit
close

play_arrow

link
brightness_4
code

// Import the os module
const os = require("os");
  
let osVersion = os.version();
console.log("OS Version:", osVersion);

chevron_right


Output:

OS Version: #24~18.04.1-Ubuntu SMP Mon Jul 28 16:12:28 UTC 2019

Example 2: On Windows

filter_none

edit
close

play_arrow

link
brightness_4
code

// Import the os module
const os = require("os");
  
let osVersion = os.version();
console.log("OS Version:", osVersion);

chevron_right


Output:

OS Version: Windows 10 Enterprise

Reference: https://nodejs.org/api/os.html#os_os_version

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.