Node.js Tutorial

Node.js OS Module

Node.js OS Module

Node.js OS Module

The Node.js OS module provides utility functions that interact with the operating system. It helps access information such as CPU details, memory usage, network interfaces, and system uptime ÔÇö making it easier to build system-aware applications.

Node.js Tutorial:-
Complete Python Course:-

Frequently Used OS Methods

  • os.arch() ÔÇö CPU architecture.
  • os.cpus() ÔÇö array of CPU/core details (model, speed).
  • os.freemem() / os.totalmem() ÔÇö free and total memory in bytes.
  • os.homedir() / os.tmpdir() ÔÇö home and temp directories.
  • os.hostname() ÔÇö system hostname.
  • os.platform() / os.type() ÔÇö OS platform and name.
  • os.uptime() ÔÇö system uptime in seconds.
  • os.networkInterfaces() ÔÇö network interface details.

Example 1: Basic OS Info

// os_example1.js
const os = require('os');
console.log("Free memory:", os.freemem());
console.log("Home dir:", os.homedir());
console.log("Hostname:", os.hostname());
console.log("Platform:", os.platform());
console.log("Total memory:", os.totalmem());
console.log("OS type:", os.type());
console.log("Uptime:", os.uptime());

// Run: node os_example1.js

Example 2: CPU and Network Info

// os_example2.js
const os = require('os');
console.log("CPUs:", os.cpus());
console.log("Arch:", os.arch());
console.log("Network:", os.networkInterfaces());

// Run: node os_example2.js

Download New Real Time Projects:- Click here
Complete Advance AI topics:-

Final Thought

The OS module is handy for fetching system-level information directly in your application ÔÇö useful for monitoring tools, resource optimization, or learning how your system interacts with Node.js. Stay tuned to for more practical Node.js tutorials.

path module in node js
util module in node js
file system module in node js
crypto module in node js
node js os module example
node js os module list
os module python
node js os module w3schools

Source Code Available

Interested in This Project?

Get the complete source code for this project at a very affordable price — perfect for your portfolio, college submission, or learning. Message us on WhatsApp and we'll get back to you instantly!

Full source code included Step-by-step setup guide Instant delivery on WhatsApp Instant reply on WhatsApp
Chat on WhatsApp

We usually reply within a few minutes

Leave a Reply

Your email address will not be published. Required fields are marked *

Chat with us