|
|
4 years ago | |
|---|---|---|
| .. | ||
| node_modules | 4 years ago | |
| index.js | 4 years ago | |
| license | 4 years ago | |
| package.json | 4 years ago | |
| readme.md | 4 years ago | |
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