OS

Node.js os module — operating system utility functions. All system queries backed by Rust FFI to libc calls. Signal and errno constants are platform-aware (macOS vs Linux).

Module: node:os Support: Experimental Since: 1.1.0 Docs: Node.js Docs

23 members: 23 undocumented

Static Methods

⚪ arch()
Returns the CPU architecture of the process (e.g. "x64", "arm64").
⚪ cpus()
Returns an array of objects describing each logical CPU core.
⚪ endianness()
Returns the endianness of the CPU: "BE" (big-endian) or "LE" (little-endian).
⚪ freemem()
Returns the amount of free system memory in bytes.
⚪ homedir()
Returns the current user's home directory path.
⚪ hostname()
Returns the host name of the operating system.
⚪ loadavg()
Returns the 1, 5, and 15-minute system load averages.
⚪ networkInterfaces()
Returns an object mapping interface names to their address entries.
⚪ platform()
Returns the operating system platform (e.g. "linux", "darwin", "win32").
⚪ release()
Returns the OS release version string.
⚪ tmpdir()
Returns the operating system's default directory for temporary files.
⚪ totalmem()
Returns the total amount of system memory in bytes.
⚪ type()
Returns the OS name (e.g. "Linux", "Darwin", "Windows_NT").
⚪ uptime()
Returns the system uptime in seconds.
⚪ userInfo(options)
Returns information about the currently effective user.
⚪ machine()
Returns the machine type as a string, such as "arm64", "x86_64", etc.
⚪ version()
Returns the operating system kernel version string.
⚪ availableParallelism()
Returns an estimate of the default amount of parallelism a program should use,
⚪ getPriority(pid)
Returns the scheduling priority for the process specified by pid.
⚪ setPriority(pid, priority)
Sets the scheduling priority for the process specified by pid.

Properties

⚪ EOL
The operating system end-of-line character sequence (`\n` on POSIX, `\r\n` on Windows).
⚪ devNull
The null device path (`/dev/null` on POSIX, `\\.\nul` on Windows).
⚪ constants
→ object

---

Details

loadavg()

static loadavg(): sequence

static loadavg(): sequence<f64>

Returns the 1, 5, and 15-minute system load averages.

Returns: sequence<f64> Array of three load average values

> Known issue: Always returns [0, 0, 0] on Windows

Dictionary CpuInfo

Information about a single logical CPU core.

Since: 1.1.0 Docs: Node.js Docs

3 members: 3 undocumented

Properties

⚪ model
Information about a single logical CPU core.
⚪ speed
CPU model name string.
⚪ times
Object with user, nice, sys, idle, and irq time fields (in milliseconds).

---

Dictionary NetworkInterface

Information about a single network interface address entry.

Since: 1.1.0 Docs: Node.js Docs

6 members: 6 undocumented

Properties

⚪ address
Information about a single network interface address entry.
⚪ netmask
Subnet mask.
⚪ family
Subnet mask.
⚪ mac
MAC address.
⚪ internal
MAC address.
⚪ cidr
CIDR notation combining address and netmask.

---