Find the root directory of a npm package
$ npm install --save pkg-dir
/ └── Users └── sindresorhus └── foo ├── package.json └── bar ├── baz └── example.js
// example.js var pkgDir = require('pkg-dir'); pkgDir(__dirname).then(function (rootPath) { console.log(rootPath); //=> '/Users/sindresorhus/foo' });
Returns a promise that resolves to the package root path or null
.
Returns the package root path or null
.
Type: string
Default: process.cwd()
Directory to start from.
MIT © Sindre Sorhus