process.platform

A string identifying the operating system platform Node is running on.

Since Node 0.x Spec ↗

Syntax

process.platform

Returns

string — One of 'darwin', 'linux', 'win32', 'freebsd', 'aix', etc.

Examples

console.log(process.platform);
Output
darwin
const open = process.platform === 'win32' ? 'start' : 'open';
console.log(`use "${open}" to open files`);
Output
use "open" to open files

Notes

Windows is always `'win32'` even on 64-bit. Use this for OS-specific behavior; use `process.arch` for CPU architecture and `os.platform()` for the equivalent from the os module.

See also