Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/shinnn/npm-cli-version

Get the currently installed npm version
https://github.com/shinnn/npm-cli-version

async javascript nodejs npm promise version

Last synced: 27 days ago
JSON representation

Get the currently installed npm version

Awesome Lists containing this project

README

        

# npm-cli-version

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

Get the currently installed [`npm` CLI](https://github.com/npm/cli) version

```javascript
const npmCliVersion = require('npm-cli-version');

(async () => {
await npmCliVersion(); //=> '5.5.1'
})();
```

Unlike the [prior](https://github.com/ngryman/npm-v) [arts](https://github.com/vvo/npm-version), it doesn't [execute](https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback) `npm --version` in a child process.

## Installation

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

```
npm install npm-cli-version
```

## API

```javascript
const npmCliVersion = require('npm-cli-version');
```

### npmCliVersion()

Return: `Promise`

## Related projects

* [parse-npm-version](https://github.com/shinnn/parse-npm-version) — Similar to this module, but returns a `Promise` for a [node-semver](https://github.com/npm/node-semver) object instead
* [npm-cli-dir](https://github.com/shinnn/npm-cli-dir) — Resolve the directory path where `npm` CLI is installed. Used by this module.

## License

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