1. Home
  2. Node
  3. Os module

OS module is a native Node module giving you access to operating system information like memory, architecture, uptime and many more.

#node#module
const os = require('os'); // Node native module

function logOsData(){

    console.log(`Architecture: ${ os.arch() }`);
    console.log(`Total memory: ${ os.totalmem() }`);
    console.log(`Free memory: ${ os.freemem()} `);
    console.log(`Platform: ${ os.platform()} `);
    console.log(`Type: ${ os.type()} `);
    console.log(`Uptime: ${ os.uptime()} `);

    // Uncomment the line below to log full OS object in the console.
    // console.log(os); 
}

logOsData();
copy
Full Node cheatsheet