Node.js OS Module
The os module in Node.js is used
to get information about the operating system and computer.
Example
const os = require("os");
console.log("Operating System:", os.platform());
console.log("Architecture:", os.arch());
console.log("Hostname:", os.hostname());
console.log("CPU Cores:", os.cpus().length);
Example Output:
Operating System: win32
Architecture: x64
Hostname: Computer-Name
CPU Cores: 8
Common OS Methods
- platform() - Returns operating system
- arch() - Returns CPU architecture
- hostname() - Returns computer name
- cpus() - Returns CPU information
- totalmem() - Returns total memory
- freemem() - Returns available memory
↠Back to Home