Skip to content
Related Articles
Open in App
Not now

Related Articles

Node.js process.getgroups() Method

Improve Article
Save Article
  • Last Updated : 30 Aug, 2022
Improve Article
Save Article

The process.getgroups() method is an inbuilt application programming interface of the Process module which is used to get the supplementary group IDs. 

Syntax:

process.getgroups()

Parameters: This method does not accept any parameters. 

Return: It returns an integer array specifying supplementary group IDs. 

Note: This function will only work on POSIX platforms. Not available on windows or android platforms so will cause an error i.e. TypeError, getgroups is not a function. 

Below examples illustrate the use of process.getgroups() method in Node.js: 

Example 1: 

javascript




// Allocating process module
const process = require('process');
 
// Printing  the supplementary group IDs.
console.log(process.getgroups());


Output:

[0]

Example 2: 

javascript




// Allocating process module
const process = require('process');
 
// Checking whether the method exists or not
if (process.getgroups) {
 
    // Printing getgroups() values
  console.log("The supplementary group IDs :"
               + process.getgroups());
}


Output:

The supplementary group IDs :[0]

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

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!