Home » Node.js

Node OS Module

Node OS Module: In this tutorial, we are going to learn about the Node OS Module with its examples.
Submitted by Godwill Tetah, on June 02, 2019

Node modules are like libraries which help us perform specific tasks. Node.js is always considered powerful because it has a very large ecosystem of third-party modules.

The OS module is a built-in module used to get information about the computer's operating system and other important information about a system.

Take Note! You should have Node js in your PC.

With Node.js already up and running, let's get started.

Now, let's get started.

The OS module is an object where we make use of it's various properties to get the information we desire.

For example, os.arch() gives us the operating system CPU architecture.

Below, we'll see how to get information about the computer's free memory, platform, architecture and host name on the console.

Open a text editor and type the following code and save it with the file name app.js:

const os = require('os'); // include the OS module

console.log("Platform: " + os.platform());
console.log("Architecture: " + os.arch());
console.log (" Free memory: "  + os.freemem() );
console.log("Host name: " + os.hostname());

Note: The file should be saved in your default Node.js directory.

Run the code by initiating the file at the command prompt like a regular Node.js file.

Node OS module






Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.
Learn PCB Designing: PCB DESIGNING TUTORIAL




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.