Node.js module

os

The 'node:os' module provides operating system-related utility methods and properties, such as CPU architecture, memory usage, uptime, user information, network interfaces, and platform details.

It is useful for gathering runtime environment data and making OS-specific decisions.

Fully supported in Bun

Fully implemented. 100% of Node.js's test suite passes.

Functions 20

  • os.arch()

    Returns the operating system CPU architecture for which the Node.js binary was compiled.

  • os.availableParallelism()

    Returns an estimate of the default amount of parallelism a program should use.

  • os.cpus()

    Returns an array of objects containing information about each logical CPU core.

  • os.endianness()

    Returns a string identifying the endianness of the CPU for which the Node.js binary was compiled.

  • os.freemem()

    Returns the amount of free system memory in bytes as an integer.

  • os.getPriority()

    Returns the scheduling priority for the process specified by pid.

  • os.homedir()

    Returns the string path of the current user's home directory.

  • os.hostname()

    Returns the host name of the operating system as a string.

  • os.loadavg()

    Returns an array containing the 1, 5, and 15 minute load averages.

  • os.machine()

    Returns the machine type as a string, such as arm, arm64, aarch64,

  • os.networkInterfaces()

    Returns an object containing network interfaces that have been assigned a network address.

  • os.platform()

    Returns a string identifying the operating system platform for which the Node.js binary was compiled.

  • os.release()

    Returns the operating system as a string.

  • os.setPriority()

    Attempts to set the scheduling priority for the process specified by pid.

  • os.tmpdir()

    Returns the operating system's default directory for temporary files as a string.

  • os.totalmem()

    Returns the total amount of system memory in bytes as an integer.

  • os.type()

    Returns the operating system name as returned by uname(3).

  • os.uptime()

    Returns the system uptime in number of seconds.

  • os.userInfo()

    Returns information about the currently effective user.

  • os.version()

    Returns a string identifying the kernel version.

Interfaces 8

Types 2

Variables 2

Namespaces 1