Node.js OS (original) (raw)

Last Updated : 17 Jan, 2026

The os module provides access to operating system information such as hostname, CPU details, and memory usage, including free system memory in bytes.

Features

The os module offers utilities to inspect system details, monitor resources, and detect the operating system platform.

**Example: Uses Node.js os module to fetch and display system details and memory info.

JavaScript `

// Include os module and create its object const os = require('os');

// return the cpu architecture console.log("CPU architecture: " + os.arch());

// It returns the amount of free system memory in bytes console.log("Free memory: " + os.freemem());

// It return total amount of system memory in bytes console.log("Total memory: " + os.totalmem());

// It returns the list of network interfaces console.log('List of network Interfaces: ' + os.networkInterfaces());

// It returns the operating systems default directory for temp files. console.log('OS default directory for temp files : ' + os.tmpdir());

`

**Output:

**Example: Displays system endianness, hostname, OS name, platform, and release using the Node.js os module.

JavaScript `

// Include os module and create its object const os = require('os');

// return the endianness of system console.log("Endianness of system: " + os.endianness());

// It returns hostname of system console.log("Hostname: " + os.hostname());

// It return operating system name console.log("Operating system name: " + os.type());

// It returns the platform of os console.log('operating system platform: ' + os.platform());

// It returns the operating systems release. console.log('OS release : ' + os.release());

`

**Output:

Benefits

Also Check: