← All notes

Node.js os - CPU count, memory, platform, home and temp directories

Answer: Use os.totalmem() for system memory, os.platform() for the platform, and os.homedir() and os.tmpdir() for directories. The node:os module provides operating system-related utility methods and properties.

Examples

import os from 'node:os';

const workers = os.availableParallelism();      // size a worker pool
const freeMiB = Math.round(os.freemem() / 2 ** 20);
const totalMiB = Math.round(os.totalmem() / 2 ** 20);

os.platform();     // 'linux', 'darwin', 'win32', ...
os.arch();         // 'x64', 'arm64', ...
os.type();         // 'Linux', 'Darwin', 'Windows_NT'
os.hostname();
os.homedir();      // uses $HOME on POSIX
os.tmpdir();       // no trailing slash
os.loadavg();      // [1, 5, 15] minute averages

const lines = ['a', 'b'].join(os.EOL);          // \n or \r\n

Functions

| Function | Returns | |---|---| | os.availableParallelism() | an estimate of the default amount of parallelism a program should use; always greater than zero | | os.cpus() | an array of objects with information about each logical CPU core; can be empty | | os.freemem() / os.totalmem() | free and total system memory in bytes | | os.platform() | the operating system platform the Node.js binary was compiled for | | os.arch() | the CPU architecture the Node.js binary was compiled for | | os.homedir() | the current user's home directory path | | os.tmpdir() | the operating system's default directory for temporary files | | os.loadavg() | the 1, 5, and 15 minute load averages | | os.networkInterfaces() | network interfaces that have been assigned a network address |

Rules

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Node.js API docs, OS; nodejs/node (GitHub), doc/api/os.md. MIT (https://raw.githubusercontent.com/nodejs/node/main/LICENSE). Copyright Node.js contributors. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Node.js API docs, OS; nodejs/node (GitHub), doc/api/os.md. MIT (https://raw.githubusercontent.com/nodejs/node/main/LICENSE). Copyright Node.js contributors.

Cite this

Permanent ID: iil:note:stg2c0mq

iinventedlight. 2026. "Node.js os - CPU count, memory, platform, home and temp directories." iinventedlight Library, iil:note:stg2c0mq, version of 2026-11-18. https://iinventedlight.com/library/notes/node-os/. License: CC-BY-4.0.

@misc{iil_note_stg2c0mq,
  author = {{iinventedlight}},
  title = {{Node.js os - CPU count, memory, platform, home and temp directories}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-18},
  url = {https://iinventedlight.com/library/notes/node-os/},
  note = {Permanent ID iil:note:stg2c0mq. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/node-os.md.