os-name

Get the name of the current operating system. Example: macOS Sierra

MIT 19 个版本
安装
npm install os-name
yarn add os-name
pnpm add os-name
bun add os-name
README

os-name

Get the name of the current operating system
Example: macOS Sierra

Useful for analytics and debugging.

Install

npm install os-name

Usage

import osName from 'os-name';

// On a macOS Sierra system

osName();
//=> 'macOS Sierra'

// On an Ubuntu system

osName();
//=> 'Ubuntu 20.04.1 LTS'

osName('darwin', '14.0.0');
//=> 'OS X Yosemite'

osName('linux', '3.13.0-24-generic');
//=> 'Linux 3.13'

osName('win32', '6.3.9600');
//=> 'Windows 8.1'

API

osName(platform?, release?)

By default, the name of the current operating system is returned.

On Linux, it reads the pretty name from /etc/os-release when available (e.g., 'Ubuntu 20.04.1 LTS', 'Debian GNU/Linux 12 (bookworm)'). When a custom release is provided, it falls back to 'Linux <version>'.

You can optionally supply a custom os.platform() and os.release().

版本列表
7.0.0 2026-02-02
6.1.0 2025-05-22
6.0.0 2023-11-24
5.1.0 2022-12-07
5.0.1 2021-11-11
5.0.0 2021-08-12
4.0.1 2021-07-28
4.0.0 2020-08-29
3.1.0 2019-04-05
3.0.0 2018-11-20
2.0.1 2016-06-20
2.0.0 2016-06-19
1.0.3 2015-01-28
1.0.2 2015-01-17
1.0.1 2014-10-06
1.0.0 2014-08-14
0.1.2 2014-06-08
0.1.1 2014-06-07
0.1.0 2014-06-07