Node.js process.getgroups() Method
Last Updated :
28 Apr, 2025
Improve
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:
// Allocating process module
const process = require('process');
// Printing the supplementary group IDs.
console.log(process.getgroups());
Output:
[0]
Example 2:
// 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