schangxiang@126.com
2025-09-19 0821aa23eabe557c0d9ef5dbe6989c68be35d1fe
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# os-name [![Build Status](https://travis-ci.org/sindresorhus/os-name.svg?branch=master)](https://travis-ci.org/sindresorhus/os-name)
 
> Get the name of the current operating system. Example: `OS X Mavericks`
 
Useful for analytics and debugging.
 
 
## Install
 
```sh
$ npm install --save os-name
```
 
 
## Usage
 
```js
var os = require('os');
var osName = require('os-name');
 
// on an OS X Mavericks system
 
osName();
//=> OS X Mavericks
 
osName(os.platform(), os.release());
//=> OS X Mavericks
 
osName(os.platform());
//=> OS X
 
osName('linux', '3.13.0-24-generic');
//=> Linux 3.13
 
osName('win32', '6.3.9600');
//=> Windows 8.1
 
osName('win32');
// Windows
```
 
 
## API
 
### osName([platform, release])
 
By default the name of the current operating system is returned.
 
You can optionally supply a custom [`os.platform()`](http://nodejs.org/api/os.html#os_os_platform) and [`os.release()`](http://nodejs.org/api/os.html#os_os_release).
 
Check out [getos](https://github.com/wblankenship/getos) if you need the Linux distribution name.
 
 
## CLI
 
```sh
$ npm install --global os-name
```
 
```sh
$ os-name --help
 
  Example
    os-name
    OS X Mavericks
```
 
 
## Contributing
 
Production systems depend on this package for logging / tracking. Please be careful when introducing new output, and adhere to existing output format (whitespace, capitalization, etc.).
 
 
## License
 
MIT © [Sindre Sorhus](http://sindresorhus.com)