process.geteuid()


process.geteuid() 方法返回进程的数值有效用户身份。(参见 geteuid(2)。)

【The process.geteuid() method returns the numerical effective user identity of the process. (See geteuid(2).)】

import process from 'node:process';

if (process.geteuid) {
  console.log(`Current uid: ${process.geteuid()}`);
}const process = require('node:process');

if (process.geteuid) {
  console.log(`Current uid: ${process.geteuid()}`);
}

此功能仅在 POSIX 平台上可用(即不包括 Windows 或 Android)。

【This function is only available on POSIX platforms (i.e. not Windows or Android).】