How to get the current OS name and version in Node.js

1 Answer

0 votes
const os = require('os');

// Get the platform (e.g., 'win32', 'linux', 'darwin')
const osPlatform = os.platform();

// Get the release/version (e.g., '10.0.19041' for Windows 10)
const osRelease = os.release();

console.log(`Operating System Platform: ${osPlatform}`);
console.log(`Operating System Version: ${osRelease}`);



   
/*
run:
    
Operating System Platform: linux
Operating System Version: 5.10.226-214.880.amzn2.x86_64
       
*/

 



answered Mar 27, 2025 by avibootz

Related questions

1 answer 102 views
1 answer 110 views
1 answer 109 views
1 answer 110 views
1 answer 118 views
1 answer 101 views
3 answers 124 views
...