# get-os-info

> This library allows you to get a correct OS name and version

Latest version **1.0.2** (published 2022-05-19) · ISC license · 0 weekly downloads

## Install

```sh
npm install get-os-info
pnpm add get-os-info
yarn add get-os-info
bun add get-os-info
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2022-05-19 |
| First published | 2022-05-19 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 8.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Artem-Babich |
| Maintainers | artem-babich |

## Links

- npm: https://www.npmjs.com/package/get-os-info
- Repository: https://github.com/Artem-Babich/get-os-info
- Homepage: https://github.com/Artem-Babich/get-os-info#readme
- Issues: https://github.com/Artem-Babich/get-os-info/issues
- npm.io page: https://npm.io/package/get-os-info

## Dependencies (4)

- [getos](https://npm.io/package/getos.md) ^3.2.1
- [os-family](https://npm.io/package/os-family.md) ^1.1.0
- [macos-release](https://npm.io/package/macos-release.md) ^3.0.1
- [windows-release](https://npm.io/package/windows-release.md) ^5.0.1

## Recent versions

- 1.0.2 (latest) — 2022-05-19
- 1.0.1 — 2022-05-19

## README

# get-os-info

> Get the name and version of the local OS

> This package is based on the [macos-release](https://www.npmjs.com/package/macos-release)
> , [windows-release](https://www.npmjs.com/package/windows-release) and [getos](https://www.npmjs.com/package/getos)
> packages.

## Install

```
$ npm install get-os-info
```

## Usage

### TypeScript

```ts
import getOSInfo, { OSInfo } from 'get-os-info'

const info: OSInfo | null = await getOSInfo();

if (info)
    console.log(info.name, info.version)

// Example:
// {
//   name: 'Windows',
//   version: '11'
// }

```

### JavaScript

```js
import { getOSInfo } from 'get-os-info';
//or
const { getOSInfo } = require('get-os-info');

const info = await getOSInfo();
```

### Separate functions

```js
import os from 'os'
import { getMacInfo, getWindowsInfo, getLinuxInfo } from "get-os-info";
//or
const os = require("os");
const { getMacInfo, getWindowsInfo, getLinuxInfo } = require('get-os-info')

const release = os.release(); //'10.0.22000'

getWindowsInfo(release).then(info => {
    if (info)
        console.log(info);
})
// {
//   name:    'Windows',
//   version: '11'
// }

console.log(await getWindowsInfo()) // Will be the same
```

> NOTE: Currently it is not possible to pass a release version argument to the getLinuxInfo function.

## Related

- [windows-release](https://github.com/sindresorhus/windows-release)
- [macos-release](https://github.com/sindresorhus/macos-release)
- [getos](https://github.com/retrohacker/getos)

---

---
_Source: https://npm.io/package/get-os-info · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
