Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Node.js process Object

  • Last Updated : 31 Mar, 2021

A process object is a global object, so it can be accessed from anywhere. As it is a predefined library, so we don’t have to download it to our system globally.

Prerequisites:

  • Basic knowledge of  Node
  • Node.js installed (version 12+)
  • NPM installed (version 6+)

Requiring Module: You can include the module using the following code:

var process = require('process');

Note: It’s a global object, so no need to install it explicitly.

Example 1: Create a JavaScript file index.js and write down the following code:

index.js




// Including the module into out project
var process = require('process');
  
// It will return the current working directory
console.log('this is the working directory --> ' + process.cwd());
  
// It will return the version of process we are using
console.log('this is the process version --> ' + process.version);
  
// It will return the type of OS we are using at that time.
console.log('current OS we are using --> ' + process.platform);

Run the index.js file using the following command:

node index.js

Output:

Example 2: Create a JavaScript file index.js and write down the following code:

index.js




// Including the module into out project
var process = require('process');
  
// It will return the Feature Object
console.log('Feature Property: ', process.features);

Run the index.js file using the following command:

node index.js

Output:

Feature Property:  {   
  inspector: true,     
  debug: false,        
  uv: true,
  ipv6: true,
  tls_alpn: true,      
  tls_sni: true,       
  tls_ocsp: true,      
  tls: true,
  cached_builtins: true
}

Reference: https://nodejs.org/api/process.html#process_process

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!