Node.js › Core Node.js Modules
What does the node:os module provide, and what are some commonly used functions from it?
BeginnerAnswer
os exposes OS-level info: platform() (OS name), cpus() (core details), totalmem()/freemem() (memory stats), homedir(), and tmpdir() -- useful for cross-platform scripts, sizing worker pools, and diagnostic logging.
console.log('Platform:', os.platform());
console.log('Free memory (GB):', (os.freemem() / 1e9).toFixed(2));Real-world example A monitoring script logs os.freemem() and os.cpus().length to help diagnose whether periodic slowdowns stem from low memory or insufficient CPU cores.