NodeJS OS module methods and properties

Nodejs OS module :

os module provides a couple of different utility methods and properties related to the operating system. It is an useful module if you want to make sure that your program will work on all different operating systems.

In this blog post, we are listing down all different constants and methods you can access using the os module.

How to use this module :

You need to import this module if you want to access its methods :

const os = require('os')

Properties :

os.EOL :

It returns the end-of-line marker. This value is operating system specific.

Constants :

You can receive different types of OS related constants in Nodejs :

  1. os.constants.signals: signal constants
  2. os.constants.errno: Error constants
  3. os.constants.dlopen: dlopen constants
  4. os.constants.priority: priority constants

Few more constants are available in Nodejs. You can check here to learn more on it.

Methods :

1. os.arch():

Get the architecture of the OS.


Get all CPUs in the OS.


Get the endianness of the CPU.


Get the amount of free memory in bytes.


Scheduling priority of the process with process id pid.


Get the home directory.


Get the hostname of the home directory.


Get 1, 5 and 15 minutes load average.


Get the information of all network interfaces.


Get the OS name.


Get the platform of the OS.

os.setPriority([pid, ]priority):

Set the scheduling priority of a process with id pid.


Get the default temporary file directory for the current OS.


Get the total memory in bytes.


Get the OS name.


Get the system uptime seconds.


Get the information on the current effective user.

That’s all. You can go through the link provided above to learn in detail.

Where is the color and why codevscolor ?

Long story short, I love paintings and I paint on weekends. We(me and my wife) have one Youtube channel. Below is a video that I did recently. If you love this please do subscribe to support us 😊❤️❤️