Working with OS Module in Node.JS

In this post we will take a quick look on OS module in Node.js. OS module is to work with OS component. It provides some functionality to work with Operating System. Using this module you can get following information like below,

  • OS target version
  • Host name
  • OS temp folder
  • Total memory in system
  • Free memory in system
  • Load on system etc.

To work with os module you need to load the module first. You can load module as given below,


After loading os module you can use it to display operating system temp directory as below,


You can access host name as following,


You can access total memory and free memory as below,


You can access OS type and platform as below,


You can fetch CPU information as below,


Node will return output as below,


We saw that os module is very important to fetch information about operating system. Putting all together you can get various os information as below,

var os = require('os');

I hope you find this quick post on Node os module useful. Thanks for reading.

3 thoughts on “Working with OS Module in Node.JS

  1. Hi sir,
    i m reading your post on node.js.. i had done all the steps which are required for executing the node files. i m able to run node files with command prompt but not able to understand that what is the procedure to execute these code in html files.. plz do the reply ASAP..
    tnx :)

  2. You have to write client if you are creating service on Node. Else use Express framework to create Node based web applications.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s