# parse-npm-version

> Get the currently installed CLI npm version and parse it with node-semver

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

## Install

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

## 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-08 |
| First published | 2017-06-05 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 3.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Shinnosuke Watanabe |
| Maintainers | shinnn |
| Keywords | npm, cli, version, semver, parse, major, minor, patch, promise, async |

## Links

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

## Dependencies (2)

- [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

## 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-08
- 1.0.0 — 2018-07-10
- 0.4.0 — 2018-07-10
- 0.3.0 — 2018-06-20
- 0.2.0 — 2017-06-08
- 0.1.0 — 2017-06-07
- 0.0.0 — 2017-06-05

## README

# parse-npm-version

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

Parse the installed [`npm` CLI](https://github.com/npm/cli) version with [`node-semver`](https://github.com/npm/node-semver)

```javascript
const parseNpmVersion = require('parse-npm-version');

(async () => {
  const result = await parseNpmVersion(); /* SemVer {
    raw: '6.7.0',
    major: 6,
    minor: 7,
    patch: 0,
    prerelease: [],
    ...
  } */
})();
```

## Installation

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

```
npm install parse-npm-version
```

## API

```javascript
const parseNpmVersion = require('parse-npm-version');
```

### parseNpmVersion()

Return: `Promise<SemVer>`

The resultant promise will be fulfilled with a [`SemVer`](https://github.com/npm/node-semver/blob/v5.6.0/semver.js#L287) instance for the current [`npm --version`](https://docs.npmjs.com/misc/config#version).

```javascript
(async () => {
  const result = await parseNpmVersion();

  result.constructor.name; //=> 'SemVer'
  result.toString(); //=> '6.7.0'

  result.compare('6.6.0'); //=> 1
  result.compare('6.7.0'); //=> 0
  result.compare('6.8.0'); //=> -1
})();
```

## Related project

* [npm-cli-version](https://github.com/shinnn/npm-cli-version) — Similar to this module, but gets a raw version `string` instead of a `SemVer` object

## License

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

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