Lesson 12 / 30

The os Module

Inspect the platform, CPU count and memory of the host machine with the os module.

System info

Useful for logging, diagnostics, or scaling decisions (e.g. worker count).

import os from "node:os";

console.log(os.platform());     // 'linux'
console.log(os.cpus().length);  // number of cores
console.log(os.totalmem());     // bytes
console.log(os.homedir());