DEV Community

Neha Sharma
Neha Sharma

Posted on • Edited on

4

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'

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free