# npm-version-compare

> Compare npm CLI version string with another version string

Latest version **1.0.1** (published 2019-02-10) · ISC license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-02-10 |
| First published | 2018-07-10 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 4.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Shinnosuke Watanabe |
| Maintainers | shinnn |
| Keywords | npm, cli, version, semver, parse, major, minor, patch, compare, comparison, promise, async |

## Links

- npm: https://www.npmjs.com/package/npm-version-compare
- Repository: https://github.com/shinnn/npm-version-compare
- Homepage: https://github.com/shinnn/npm-version-compare#readme
- Issues: https://github.com/shinnn/npm-version-compare/issues
- npm.io page: https://npm.io/package/npm-version-compare

## Dependencies (3)

- [import-package](https://npm.io/package/import-package.md) ^1.0.0
- [npm-cli-version](https://npm.io/package/npm-cli-version.md) ^1.0.0
- [inspect-with-kind](https://npm.io/package/inspect-with-kind.md) ^1.0.5

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2019-02-10
- 1.0.0 — 2018-07-10
- 0.0.0 — 2018-07-10

## README

# npm-version-compare

[![npm version](https://img.shields.io/npm/v/npm-version-compare.svg)](https://www.npmjs.com/package/npm-version-compare)
[![Build Status](https://travis-ci.com/shinnn/npm-version-compare.svg?branch=master)](https://travis-ci.com/shinnn/npm-version-compare)
[![Coverage Status](https://img.shields.io/coveralls/shinnn/npm-version-compare.svg)](https://coveralls.io/github/shinnn/npm-version-compare?branch=master)

Compare [npm CLI](https://github.com/npm/cli) version string with another version string

```javascript
const npmVersionCompare = require('npm-version-compare');

// When npm CLI v6.7.0 is installed

(async () => {
  await npmVersionCompare('6.6.0'); // 1
  await npmVersionCompare('6.7.0'); // 0
  await npmVersionCompare('6.8.0'); // -1
})();
```

## Installation

[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/getting-started/about-npm/).

```
npm install npm-version-compare
```

## API

```javascript
const npmVersionCompare = require('npm-version-compare');
```

### npmVersionCompare(*version*)

*version*: `string` ([SemVer](https://semver.org/) version expression)  
Return: `Promise<integer>` (`-1`, `0` or `1`)

The resultant promise will be fulfilled with:

* `-1` if a given version is greater than the version of currently installed `npm`
* `0` if a given version is the same value as the `npm` version
* `1` if the `npm` version is greater than a given version

## Related project

* [npm-cli-version](https://github.com/shinnn/npm-cli-version) — Get the currently installed npm version

## License

[ISC License](./LICENSE) © 2018 - 2019 Shinnosuke Watanabe

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