Node js | OS
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:
// Include os module and create its object var os = require('os'); // return the cpu architecture console.log("CPU architecture: " + os.arch()); // It returns the amount of free system memory in bytes console.log("Free memory: " + os.freemem()); // It return total amount of system memory in bytes console.log("Total memory: " + os.totalmem()); // It returns the list of network interfaces console.log('List of network Interfaces: ' + os.networkInterfaces()); // It returns the operating systems default directory for temp files. console.log('OS default directory for temp files : ' + os.tmpdir ()); |
chevron_right
filter_none
Output:

Exampe 2:
// Include os module and create its object var os = require('os'); // return the endianness of sytem console.log("Endianness of system: " + os.endianness()); // It returns hostname of system console.log("Hostname: " + os.hostname()); // It return operating system name console.log("Operating system name: " + os.type()); // It returns the platform of os console.log('operating system platform: ' + os.platform()); // It returns the operating systems release. console.log('OS release : ' + os.release()); |
chevron_right
filter_none
Output:

Recommended Posts:
- Node.js | NPM (Node Package Manager)
- PHP vs. Node.js
- Why Node.js ?
- Node.js Events
- Node | URLSearchParams.set()
- HTTPS in Node
- Node | URL.pathToFileURL API
- Node | URL.fileURLToPath API
- Node | URL.protocol API
- Routing in Node.js
- Node | URL.resolve(from,to) API
- Node | URL.host API
- Node | URL.hash API
- Essence of Node.js
- Promises in Node.js
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.



