---
source: https://iinventedlight.com/library/notes/node-os.md
title: "Node.js os - CPU count, memory, platform, home and temp directories"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT (Node.js API docs); MIT (nodejs/node (GitHub)); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-18
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-18
as_of: 2026-11-18
confidence: medium
untested: "Not reproduced (2026-11-18). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-web: node os"
tags: [node, os, cpus, memory, platform, system-info]
client: Librarian
sources:
  - id: S1
    title: "OS"
    publisher: Node.js API docs
    url: https://nodejs.org/api/os.html
    accessed: 2026-11-18
    license: "MIT"
  - id: S2
    title: "doc/api/os.md"
    publisher: nodejs/node (GitHub)
    url: https://github.com/nodejs/node/blob/main/doc/api/os.md
    accessed: 2026-11-18
    license: "MIT"
---
# 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

```js
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

- `os.EOL` is the operating system-specific end-of-line marker: `\n` on POSIX and `\r\n` on Windows.
- The `os.cpus()` array will be empty if no CPU information is available, such as when /proc is unavailable.
- `os.platform()` is equivalent to `process.platform`, and `os.arch()` to `process.arch`.
- On POSIX, `os.homedir()` uses the $HOME environment variable if defined.

## See also

- [node-process-and-console](https://iinventedlight.com/library/notes/node-process-and-console/)
- [node-fs-and-path](https://iinventedlight.com/library/notes/node-fs-and-path/)
- [node-buffer](https://iinventedlight.com/library/notes/node-buffer/)

## Claims

- id: C1
  claim: os provides OS-related utilities.
  source: S1
  evidence: "The node:os module provides operating system-related utility methods and properties."

- id: C2
  claim: cpus can return an empty array.
  source: S1
  evidence: "The array will be empty if no CPU information is available"

- id: C3
  claim: availableParallelism estimates parallelism.
  source: S2
  evidence: "Returns an estimate of the default amount of parallelism a program should use."

## Sources

- [S1] OS. Node.js API docs. https://nodejs.org/api/os.html . License: MIT. Accessed 2026-11-18.

- [S2] doc/api/os.md. nodejs/node (GitHub). https://github.com/nodejs/node/blob/main/doc/api/os.md . License: MIT. Accessed 2026-11-18.

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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
