Usage
import * as mod from "node:os";
The node:os
module provides operating system-related utility methods and
properties. It can be accessed using:
const os = require('node:os');
Returns the operating system CPU architecture for which the Node.js binary was
compiled. Possible values are 'arm'
, 'arm64'
, 'ia32'
, 'loong64'
,'mips'
, 'mipsel'
, 'ppc'
, 'ppc64'
, 'riscv64'
, 's390'
, 's390x'
,
and 'x64'
.
Returns an estimate of the default amount of parallelism a program should use. Always returns a value greater than zero.
Returns an array of objects containing information about each logical CPU core.
The array will be empty if no CPU information is available, such as if the/proc
file system is unavailable.
Returns a string identifying the endianness of the CPU for which the Node.js binary was compiled.
Returns the amount of free system memory in bytes as an integer.
Returns the scheduling priority for the process specified by pid
. If pid
is
not provided or is 0
, the priority of the current process is returned.
Returns the string path of the current user's home directory.
Returns the host name of the operating system as a string.
Returns an array containing the 1, 5, and 15 minute load averages.
Returns the machine type as a string, such as arm
, arm64
, aarch64
,mips
, mips64
, ppc64
, ppc64le
, s390
, s390x
, i386
, i686
, x86_64
.
Returns an object containing network interfaces that have been assigned a network address.
Returns a string identifying the operating system platform for which
the Node.js binary was compiled. The value is set at compile time.
Possible values are 'aix'
, 'darwin'
, 'freebsd'
,'linux'
,'openbsd'
, 'sunos'
, and 'win32'
.
Returns the operating system as a string.
Attempts to set the scheduling priority for the process specified by pid
. Ifpid
is not provided or is 0
, the process ID of the current process is used.
Returns the operating system's default directory for temporary files as a string.
Returns the total amount of system memory in bytes as an integer.
Returns the system uptime in number of seconds.
Returns information about the currently effective user. On POSIX platforms,
this is typically a subset of the password file. The returned object includes
the username
, uid
, gid
, shell
, and homedir
. On Windows, the uid
andgid
fields are -1
, and shell
is null
.
Returns a string identifying the kernel version.
The node:os
module provides operating system-related utility methods and
properties. It can be accessed using: