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

← Back to Home