1 # pkg-dir [![Build Status](https://travis-ci.org/sindresorhus/pkg-dir.svg?branch=master)](https://travis-ci.org/sindresorhus/pkg-dir)
3 > Find the root directory of a Node.js project or npm package
9 $ npm install --save pkg-dir
28 const pkgDir = require('pkg-dir');
30 pkgDir(__dirname).then(rootDir => {
32 //=> '/Users/sindresorhus/foo'
41 Returns a `Promise` for either the project root path or `null` if it couldn't be found.
43 ### pkgDir.sync([cwd])
45 Returns the project root path or `null`.
50 Default: `process.cwd()`
52 Directory to start from.
57 - [pkg-dir-cli](https://github.com/sindresorhus/pkg-dir-cli) - CLI for this module
58 - [pkg-up](https://github.com/sindresorhus/pkg-up) - Find the closest package.json file
59 - [find-up](https://github.com/sindresorhus/find-up) - Find a file by walking up parent directories
64 MIT © [Sindre Sorhus](https://sindresorhus.com)