DEV Community

Neha Sharma
Neha Sharma

Posted on • Edited on

What is OS module - NodeJS

NodeJS is a powerful for tooling and creating script. NodeJS helps in automation of boring manual tasks.

NodeJS has lot of built-in packages and it is hard to pick which is the most powerful as all are equally important and powerful.

I will be sharing a series of post on each module. Starting from 'OS'.

What?

OS (operating system)

Use OS when you need information of the underlying operating System. This is pretty helpful when you are running your project on different platforms or beyond just web.

How to use it?

Just require it in your file.

const os = require('os')
Enter fullscreen mode Exit fullscreen mode

Methods

OS has a lot of methods. Here a few common ones :

os.arch() // Returns the operating system CPU architecture
Enter fullscreen mode Exit fullscreen mode
os.platform() // Returns information about the operating system's platform
Enter fullscreen mode Exit fullscreen mode
os.userInfo() // Returns information about the current user
Enter fullscreen mode Exit fullscreen mode
os.totalmem() // Returns the number of total memory of the system
Enter fullscreen mode Exit fullscreen mode
os.freemem() // Returns the number of free memory of the system
Enter fullscreen mode Exit fullscreen mode

Thanks for reading!! PS: Do check official document of the NodeJS for OS Module.

Next we will explore 'fs'

Top comments (0)