npm-cli-version
Get the currently installed
npm
CLI versionconst npmCliVersion = require('npm-cli-version');
(async () => {
await npmCliVersion(); //=> '5.5.1'
})();
Unlike the prior arts, it doesn't execute
npm --version
in a child process.Installation
Use npm.npm install npm-cli-version
API
const npmCliVersion = require('npm-cli-version');
npmCliVersion()
Return:Promise<string>
Related projects
- parse-npm-version — Similar to this module, but returns a
Promise
for a node-semver object instead - npm-cli-dir — Resolve the directory path where
npm
CLI is installed. Used by this module.