os.platform()

Returns the operating system platform string.

Since Node 0.5 Spec ↗

Syntax

os.platform()

Returns

string — Same values as process.platform: 'linux', 'darwin', 'win32', etc.

Examples

import { platform } from 'node:os';

console.log(platform());
Output
darwin
import { platform } from 'node:os';

const isWindows = platform() === 'win32';
console.log(isWindows ? 'CRLF' : 'LF');
Output
LF

Notes

Identical to `process.platform` but importable from the os module. For a human-readable OS name use `os.type()`; for the kernel release use `os.release()`.

See also