Skip to content

Resolve a path of the directory where npm CLI is installed

License

Notifications You must be signed in to change notification settings

shinnn/npm-cli-dir

Repository files navigation

npm-cli-dir

npm version Build Status codecov

A Node.js module to resolve a path of the directory where npm CLI is installed

const npmCliDir = require('npm-cli-dir');

(async () => {
  const dir = await npmCliDir(); //=> '/usr/local/lib/node_modules/npm'
})();

Installation

Use npm.

npm install npm-cli-dir

API

const npmCliDir = require('npm-cli-dir');

npmCliDir()

Return: Promise<string>

const {readdir} = require('fs').promises;
const npmCliDir = require('npm-cli-dir');

(async () => {
  await readdir(await npmCliDir());
  //=> ['.mailmap', '.npmignore', '.travis.yml', 'AUTHORS', 'CHANGELOG.md', ...]
})();

License

ISC License © 2017 - 2019 Watanabe Shinnosuke