~2 min read • Updated Dec 30, 2025
1. Basic System Information
os.arch(): CPU architecture (arm, x64, ia32, etc.).os.machine(): Machine type (arm64, mips, x86_64, etc.).os.endianness(): CPU endianness ('LE' or 'BE').os.platform(): Operating system platform (linux, win32, darwin, etc.).os.type(): OS name (Linux, Darwin, Windows_NT).os.release(): OS release version.os.version(): Kernel version.
2. CPU and Parallelism
os.cpus(): Detailed information about each CPU core.os.availableParallelism(): Recommended number of parallel threads.
3. Memory and Resources
os.freemem(): Free system memory.os.totalmem(): Total system memory.os.loadavg(): System load averages (Unix only).os.uptime(): System uptime in seconds.
4. Paths and Files
os.homedir(): Current user's home directory.os.tmpdir(): Default temporary file directory.os.devNull: Null device path (\\.\nul on Windows, /dev/null on POSIX).os.EOL: End-of-line marker (\\n on POSIX, \\r\\n on Windows).
5. User Information
os.userInfo(): Current user details (username, uid, gid, shell, homedir).os.hostname(): Hostname of the system.
6. Networking
os.networkInterfaces() returns a list of network interfaces and their assigned IP addresses.
{
lo: [
{ address: '127.0.0.1', family: 'IPv4', internal: true },
{ address: '::1', family: 'IPv6', internal: true }
],
eth0: [
{ address: '192.168.1.108', family: 'IPv4', internal: false },
{ address: 'fe80::a00:27ff:fe4e:66a1', family: 'IPv6', internal: false }
]
}
7. Process Priority
os.getPriority([pid]): Get process priority.os.setPriority([pid, priority]): Set process priority.
Values range from -20 (highest) to 19 (lowest), mapped to constants in os.constants.priority.
8. System Constants
- Signal constants: e.g., SIGINT (Ctrl+C), SIGTERM (terminate), SIGKILL (immediate kill).
- Error constants: POSIX errors (ENOENT, EACCES, ECONNREFUSED) and Windows-specific errors (WSAECONNRESET, WSAETIMEDOUT).
- dlopen constants: Dynamic loading flags like RTLD_LAZY and RTLD_NOW.
Conclusion
The os module in Node.js is a powerful tool for accessing operating system information. It allows developers to adapt applications to hardware and software conditions, manage resources, and understand system behavior more effectively.
Written & researched by Dr. Shahin Siami