OS is a node module used to provide information about the computer operating system.
Advantages:
It provides functions to interact with the operating system. It provides the hostname of the operating system and returns the amount of free system memory in bytes.
Example 1:
javascript
const os = require( 'os' );
console.log( "CPU architecture: " + os.arch());
console.log( "Free memory: " + os.freemem());
console.log( "Total memory: " + os.totalmem());
console.log( 'List of network Interfaces: ' + os.networkInterfaces());
console.log( 'OS default directory for temp files : ' + os.tmpdir());
|
Output:
Example 2:
javascript
const os = require( 'os' );
console.log( "Endianness of system: " + os.endianness());
console.log( "Hostname: " + os.hostname());
console.log( "Operating system name: " + os.type());
console.log( 'operating system platform: ' + os.platform());
console.log( 'OS release : ' + os.release());
|
Output:
Last Updated :
11 Apr, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...