Node.js process.getuid() Method
Last Updated :
12 Oct, 2021
The process.getuid() method is an inbuilt application programming interface of the process module which is used to get the numerical user identity of the Node.js process.
Syntax:
process.getuid()
Parameters: This method does not accept any parameters.
Return Value: This method returns an integer value specifying the numerical user identity of the Node.js process.
Note: This method will only work on POSIX platforms. Not available on windows or android platforms so will cause an error i.e. TypeError, getuid is not a function.
Below examples illustrate the use of process.getuid() method in Node.js:
Example 1:
const process = require( 'process' );
console.log(process.getuid());
|
Output:
6693036
Example 2:
const process = require( 'process' );
if (process.getuid) {
console.log( "The numerical user identity "
+ "of the Node.js process: "
+ process.getuid());
}
|
Output:
The numerical user identity of the Node.js process: 6693036
Note: The above program will compile and run by using the node filename.js
command.
Reference: https://nodejs.org/api/process.html#process_process_getuid
Share your thoughts in the comments
Please Login to comment...