# macos-version

> Get or check the current macOS version

Latest version **6.0.0** (published 2021-08-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install macos-version
pnpm add macos-version
yarn add macos-version
bun add macos-version
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 6.0.0 |
| Published | 2021-08-12 |
| First published | 2016-06-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Node | ^12.20.0 \|\| ^14.13.1 \|\| >=16.0.0 |
| Dependencies | 1 |
| Unpacked size | 7.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 61 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | macos, os, darwin, operating, system, platform, version, release, semver, check, assert, condition |

## Links

- npm: https://www.npmjs.com/package/macos-version
- Repository: https://github.com/sindresorhus/macos-version
- Homepage: https://github.com/sindresorhus/macos-version#readme
- Issues: https://github.com/sindresorhus/macos-version/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/macos-version

## Dependencies (1)

- [semver](https://npm.io/package/semver.md) ^7.3.5

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [mongoose-typescript](https://npm.io/package/mongoose-typescript.md) — 85 weekly downloads

## Recent versions

- 6.0.0 (latest) — 2021-08-12
- 5.2.1 — 2021-02-16
- 5.2.0 — 2019-03-31
- 5.1.0 — 2019-03-18
- 5.0.0 — 2018-12-25
- 4.1.0 — 2017-11-24
- 4.0.1 — 2017-07-07
- 4.0.0 — 2017-03-16
- 3.0.0 — 2016-06-19
- 2.1.1 — 2016-06-19

## README

# macos-version

> Get or check the current macOS version

## Install

```
$ npm install macos-version
```

## Usage

```js
import {
	macOSVersion,
	isMacOSVersion,
	isMacOSVersionGreaterThanOrEqualTo,
	assertMacOSVersion,
	assertMacOSVersionGreaterThanOrEqualTo,
	assertMacOS,
	isMacOS,
} from 'macos-version';

macOSVersion();
//=> '10.12.3'

isMacOSVersion('>10.10');
//=> true

isMacOSVersionGreaterThanOrEqualTo('10.10');
//=> true

assertMacOSVersion('>=10.12.5');
//=> [Error: Requires macOS >=10.12.5]

assertMacOSVersionGreaterThanOrEqualTo('10.12.5');
//=> [Error: Requires macOS 10.12.5 or later]

assertMacOS();
//=> [Error: Requires macOS]

if (isMacOS) {
	console.log('macOS');
}
```

## API

### macOSVersion()

Returns the macOS version or `undefined` if the platform is not macOS.

### isMacOSVersion(semverRange)

Returns a `boolean` of whether the specified [semver range](https://github.com/npm/node-semver#ranges) matches the macOS version.

### isMacOSVersionGreaterThanOrEqualTo(version)

Returns a `boolean` of whether the macOS version is greater than or equal to the specified version.

### assertMacOSVersion(semverRange)

Throws an error if the specified [semver range](https://github.com/npm/node-semver#ranges) does not match the macOS version.

### assertMacOSVersionGreaterThanOrEqualTo(version)

Throws an error if the macOS version is not greater than or equal to the specified version.

*Prefer this over `.assert()` whenever possible as it outputs a more user-friendly error message.*

### assertMacOS()

Throws an error if the platform is not macOS.

### isMacOS

Type: `boolean`

Whether the platform is macOS.

## Related

- [macos-version-cli](https://github.com/sindresorhus/macos-version-cli) - CLI for this module
- [macos-release](https://github.com/sindresorhus/macos-release) - Get the name and version of a macOS release from the Darwin version

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