{"_id":"package-directory","_rev":"4510354","name":"package-directory","description":"Find the root directory of a Node.js project or npm package","dist-tags":{"latest":"8.2.0"},"maintainers":[{"name":"sindresorhus","email":""}],"time":{"modified":"2026-04-09T12:20:43.000Z","created":"2017-05-19T15:21:15.544Z","8.2.0":"2026-02-01T14:52:22.473Z","8.1.0":"2025-06-05T18:32:07.351Z","0.2.3":"2017-05-19T16:21:58.639Z","0.2.2":"2017-05-19T16:18:03.877Z","0.2.1":"2017-05-19T16:06:35.023Z","0.2.0":"2017-05-19T15:57:32.424Z","0.1.6":"2017-05-19T15:47:30.273Z","0.1.5":"2017-05-19T15:36:39.150Z","0.1.4":"2017-05-19T15:28:49.922Z","0.1.3":"2017-05-19T15:21:15.544Z"},"users":{},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"repository":{"type":"git","url":"git+https://github.com/sindresorhus/package-directory.git"},"versions":{"8.2.0":{"name":"package-directory","version":"8.2.0","description":"Find the root directory of a Node.js project or npm package","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/package-directory.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=18"},"scripts":{"test":"xo && ava && tsd"},"keywords":["package","json","root","npm","entry","find","up","find-up","findup","look-up","look","file","search","match","resolve","parent","parents","folder","directory","walk","walking","path"],"dependencies":{"find-up-simple":"^1.0.0"},"devDependencies":{"ava":"^5.3.1","tempy":"^3.1.0","tsd":"^0.29.0","xo":"^0.56.0"},"gitHead":"516b394cc157c5c23d72ca287d9f3498dd9dd1df","types":"./index.d.ts","_id":"package-directory@8.2.0","bugs":{"url":"https://github.com/sindresorhus/package-directory/issues"},"homepage":"https://github.com/sindresorhus/package-directory#readme","_nodeVersion":"25.3.0","_npmVersion":"11.7.0","dist":{"shasum":"b4f9df2e56782beb1d805945e2c530d29a3806f9","size":2580,"noattachment":false,"key":"/package-directory/-/package-directory-8.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/package-directory/download/package-directory-8.2.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/package-directory_8.2.0_1769957542335_0.6904004299656012"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2026-02-01T14:52:22.473Z","publish_time":1769957542473,"_source_registry_name":"default","_cnpm_publish_time":1769957542473},"8.1.0":{"name":"package-directory","version":"8.1.0","description":"Find the root directory of a Node.js project or npm package","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/package-directory.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=18"},"scripts":{"test":"xo && ava && tsd"},"keywords":["package","json","root","npm","entry","find","up","find-up","findup","look-up","look","file","search","match","resolve","parent","parents","folder","directory","walk","walking","path"],"dependencies":{"find-up-simple":"^1.0.0"},"devDependencies":{"ava":"^5.3.1","tempy":"^3.1.0","tsd":"^0.29.0","xo":"^0.56.0"},"_id":"package-directory@8.1.0","gitHead":"cec34977c37bcf821379a8f257db4d5e05f8498b","types":"./index.d.ts","bugs":{"url":"https://github.com/sindresorhus/package-directory/issues"},"homepage":"https://github.com/sindresorhus/package-directory#readme","_nodeVersion":"20.19.1","_npmVersion":"10.9.2","dist":{"shasum":"75737f33380df04490de8cacb47d682116661401","size":2066,"noattachment":false,"key":"/package-directory/-/package-directory-8.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/package-directory/download/package-directory-8.1.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/package-directory_8.1.0_1749148327173_0.27648315656796085"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-06-05T18:32:07.351Z","publish_time":1749148327351,"_source_registry_name":"default","_cnpm_publish_time":1749148327351},"0.2.3":{"name":"package-directory","version":"0.2.3","description":"Specify a custom installation directory for local package.json dependencies","scripts":{"preinstall":"node install.js"},"repository":{"type":"git","url":"git+https://github.com/daluege/package-directory.git"},"author":{"name":"Filip Dalüge","email":"filip.daluge@checle.com"},"license":"MIT","bugs":{"url":"https://github.com/daluege/package-directory/issues"},"homepage":"https://github.com/daluege/package-directory","dependencies":{"findup-sync":"^1.0.0"},"gitHead":"50cd0711d73c0a5f0771dd0fb57dcc73a784f22a","_id":"package-directory@0.2.3","_shasum":"0daf7bccfd9384149dd2ba53da9917179cb70858","_from":".","_npmVersion":"4.2.0","_nodeVersion":"7.10.0","_npmUser":{"name":"daluege","email":"daluege@checle.com"},"dist":{"shasum":"0daf7bccfd9384149dd2ba53da9917179cb70858","size":2244,"noattachment":false,"key":"/package-directory/-/package-directory-0.2.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/package-directory/download/package-directory-0.2.3.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/package-directory-0.2.3.tgz_1495210917727_0.8348540863953531"},"directories":{},"_cnpmcore_publish_time":"2021-12-19T18:28:26.312Z","hasInstallScript":true,"publish_time":1495210918639,"_cnpm_publish_time":1495210918639},"0.2.2":{"name":"package-directory","version":"0.2.2","description":"Specify a custom installation directory for local package.json dependencies","scripts":{"preinstall":"node install.js"},"repository":{"type":"git","url":"git+https://github.com/daluege/package-directory.git"},"author":{"name":"Filip Dalüge","email":"filip.daluge@checle.com"},"license":"MIT","bugs":{"url":"https://github.com/daluege/package-directory/issues"},"homepage":"https://github.com/daluege/package-directory","dependencies":{"findup-sync":"^1.0.0"},"gitHead":"d62ec7572c17c04ff15725a239d7a3c89930f01e","_id":"package-directory@0.2.2","_shasum":"0bf9dd458a933826d3ed9f786f4f56e74ba0dcef","_from":".","_npmVersion":"4.2.0","_nodeVersion":"7.10.0","_npmUser":{"name":"daluege","email":"daluege@checle.com"},"dist":{"shasum":"0bf9dd458a933826d3ed9f786f4f56e74ba0dcef","size":2252,"noattachment":false,"key":"/package-directory/-/package-directory-0.2.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/package-directory/download/package-directory-0.2.2.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/package-directory-0.2.2.tgz_1495210681428_0.5816884671803564"},"directories":{},"_cnpmcore_publish_time":"2021-12-19T18:28:25.433Z","hasInstallScript":true,"publish_time":1495210683877,"_cnpm_publish_time":1495210683877},"0.2.1":{"name":"package-directory","version":"0.2.1","description":"Specify a custom installation directory for local package.json dependencies","scripts":{"install":"node install.js"},"repository":{"type":"git","url":"git+https://github.com/daluege/package-directory.git"},"author":{"name":"Filip Dalüge","email":"filip.daluge@checle.com"},"license":"MIT","bugs":{"url":"https://github.com/daluege/package-directory/issues"},"homepage":"https://github.com/daluege/package-directory","dependencies":{"findup-sync":"^1.0.0"},"gitHead":"8bccaef0a54076472a9773fd8ca5c12466eb6be0","_id":"package-directory@0.2.1","_shasum":"d6c1f8fe7d8f8f18289f7f28fabd19588d8c3241","_from":".","_npmVersion":"4.2.0","_nodeVersion":"7.10.0","_npmUser":{"name":"daluege","email":"daluege@checle.com"},"dist":{"shasum":"d6c1f8fe7d8f8f18289f7f28fabd19588d8c3241","size":2237,"noattachment":false,"key":"/package-directory/-/package-directory-0.2.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/package-directory/download/package-directory-0.2.1.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/package-directory-0.2.1.tgz_1495209994126_0.6880516118835658"},"directories":{},"_cnpmcore_publish_time":"2021-12-19T18:28:24.570Z","hasInstallScript":true,"publish_time":1495209995023,"_cnpm_publish_time":1495209995023},"0.2.0":{"name":"package-directory","version":"0.2.0","description":"Specify a custom installation directory for local package.json dependencies","scripts":{"install":"node install.js"},"repository":{"type":"git","url":"git+https://github.com/daluege/package-directory.git"},"author":{"name":"Filip Dalüge","email":"filip.daluge@checle.com"},"license":"MIT","bugs":{"url":"https://github.com/daluege/package-directory/issues"},"homepage":"https://github.com/daluege/package-directory","dependencies":{"findup-sync":"^1.0.0"},"gitHead":"40a0e0b25da1cb1b8be7f73df2009ca837c6b82d","_id":"package-directory@0.2.0","_shasum":"1316c59c37dba638558681035c7a15c0b6681b7d","_from":".","_npmVersion":"4.2.0","_nodeVersion":"7.10.0","_npmUser":{"name":"daluege","email":"daluege@checle.com"},"dist":{"shasum":"1316c59c37dba638558681035c7a15c0b6681b7d","size":2239,"noattachment":false,"key":"/package-directory/-/package-directory-0.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/package-directory/download/package-directory-0.2.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/package-directory-0.2.0.tgz_1495209451496_0.04946747003123164"},"directories":{},"_cnpmcore_publish_time":"2021-12-19T18:28:23.698Z","hasInstallScript":true,"publish_time":1495209452424,"_cnpm_publish_time":1495209452424},"0.1.6":{"name":"package-directory","version":"0.1.6","description":"Specify a custom installation directory for local package.json dependencies","scripts":{"install":"node install.js"},"repository":{"type":"git","url":"git+https://github.com/daluege/package-directory.git"},"author":{"name":"Filip Dalüge","email":"filip.daluge@checle.com"},"license":"MIT","bugs":{"url":"https://github.com/daluege/package-directory/issues"},"homepage":"https://github.com/daluege/package-directory","dependencies":{"findup-sync":"^1.0.0"},"gitHead":"fa573dcae849ad6c9a51602f30d60df5ab642006","_id":"package-directory@0.1.6","_shasum":"b6f14ad5029a288193d83f2f274cbdfb62eef360","_from":".","_npmVersion":"4.2.0","_nodeVersion":"7.10.0","_npmUser":{"name":"daluege","email":"daluege@checle.com"},"dist":{"shasum":"b6f14ad5029a288193d83f2f274cbdfb62eef360","size":2193,"noattachment":false,"key":"/package-directory/-/package-directory-0.1.6.tgz","tarball":"http://registry.cnpm.dingdandao.com/package-directory/download/package-directory-0.1.6.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/package-directory-0.1.6.tgz_1495208849288_0.5828337741550058"},"directories":{},"_cnpmcore_publish_time":"2021-12-19T18:28:22.828Z","hasInstallScript":true,"publish_time":1495208850273,"_cnpm_publish_time":1495208850273},"0.1.5":{"name":"package-directory","version":"0.1.5","description":"Specify a custom installation directory for local package.json dependencies","scripts":{"install":"node install.js"},"repository":{"type":"git","url":"git+https://github.com/daluege/package-directory.git"},"author":{"name":"Filip Dalüge","email":"filip.daluge@checle.com"},"license":"MIT","bugs":{"url":"https://github.com/daluege/package-directory/issues"},"homepage":"https://github.com/daluege/package-directory","dependencies":{"findup-sync":"^1.0.0"},"gitHead":"bf06447e2cfb4a3eb634f4575a529171d2287975","_id":"package-directory@0.1.5","_shasum":"20966def1682d3a0272fec6e504b1440aca627ea","_from":".","_npmVersion":"4.2.0","_nodeVersion":"7.10.0","_npmUser":{"name":"daluege","email":"daluege@checle.com"},"dist":{"shasum":"20966def1682d3a0272fec6e504b1440aca627ea","size":2124,"noattachment":false,"key":"/package-directory/-/package-directory-0.1.5.tgz","tarball":"http://registry.cnpm.dingdandao.com/package-directory/download/package-directory-0.1.5.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/package-directory-0.1.5.tgz_1495208198240_0.5702554685994983"},"directories":{},"_cnpmcore_publish_time":"2021-12-19T18:28:21.955Z","hasInstallScript":true,"publish_time":1495208199150,"_cnpm_publish_time":1495208199150},"0.1.4":{"name":"package-directory","version":"0.1.4","description":"Specify a custom installation directory for local package.json dependencies","scripts":{"install":"node install.js"},"repository":{"type":"git","url":"git+https://github.com/daluege/package-directory.git"},"author":{"name":"Filip Dalüge","email":"filip.daluge@checle.com"},"license":"MIT","bugs":{"url":"https://github.com/daluege/package-directory/issues"},"homepage":"https://github.com/daluege/package-directory","dependencies":{"findup-sync":"^1.0.0"},"gitHead":"077d65bcd1bec4288dafccdfe14c93f704329ff1","_id":"package-directory@0.1.4","_shasum":"fd928128e820f07d47deca80bbd766dfad22c757","_from":".","_npmVersion":"4.2.0","_nodeVersion":"7.10.0","_npmUser":{"name":"daluege","email":"daluege@checle.com"},"dist":{"shasum":"fd928128e820f07d47deca80bbd766dfad22c757","size":2115,"noattachment":false,"key":"/package-directory/-/package-directory-0.1.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/package-directory/download/package-directory-0.1.4.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/package-directory-0.1.4.tgz_1495207729012_0.16646111803129315"},"directories":{},"_cnpmcore_publish_time":"2021-12-19T18:28:21.060Z","hasInstallScript":true,"publish_time":1495207729922,"_cnpm_publish_time":1495207729922},"0.1.3":{"name":"package-directory","version":"0.1.3","description":"Specify a custom installation directory for local package.json dependencies","scripts":{"install":"node install.js"},"repository":{"type":"git","url":"git+https://github.com/daluege/package-directory.git"},"author":{"name":"Filip Dalüge","email":"filip.daluge@checle.com"},"license":"MIT","bugs":{"url":"https://github.com/daluege/package-directory/issues"},"homepage":"https://github.com/daluege/package-directory","dependencies":{"findup-sync":"^1.0.0"},"gitHead":"abb609b068067e5d80c9914698817a82e053a24b","_id":"package-directory@0.1.3","_shasum":"61eebc0f22d92a7bf290d774c1037b0b3b40c952","_from":".","_npmVersion":"4.2.0","_nodeVersion":"7.10.0","_npmUser":{"name":"daluege","email":"daluege@checle.com"},"dist":{"shasum":"61eebc0f22d92a7bf290d774c1037b0b3b40c952","size":2010,"noattachment":false,"key":"/package-directory/-/package-directory-0.1.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/package-directory/download/package-directory-0.1.3.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/package-directory-0.1.3.tgz_1495207274657_0.03573029534891248"},"directories":{},"_cnpmcore_publish_time":"2021-12-19T18:28:20.168Z","hasInstallScript":true,"publish_time":1495207275544,"_cnpm_publish_time":1495207275544}},"readme":"# package-directory\n\n> Find the root directory of a Node.js project or npm package\n\n## Install\n\n```sh\nnpm install package-directory\n```\n\n## Usage\n\n```\n/\n└── Users\n    └── sindresorhus\n        └── foo\n            ├── package.json\n            └── bar\n                ├── baz\n                └── example.js\n```\n\n```js\n// example.js\nimport {packageDirectory} from 'package-directory';\n\nconsole.log(await packageDirectory());\n//=> '/Users/sindresorhus/foo'\n```\n\n## API\n\n### packageDirectory(option?)\n\nReturns a `Promise` for either the project root path or `undefined` if it could not be found.\n\n### packageDirectorySync(options?)\n\nReturns the project root path or `undefined` if it could not be found.\n\n#### options\n\nType: `object`\n\n##### cwd\n\nType: `string`\\\nDefault: `process.cwd()`\n\nThe directory to start searching from.\n\n##### ignoreTypeOnlyPackageJson\n\nType: `boolean`\\\nDefault: `false`\n\nIgnore `package.json` files that only contain the `type` field.\n\nThis treats `{\"type\":\"module\"}` files as ESM scope markers instead of package roots.\n\n## Related\n\n- [package-directory-cli](https://github.com/sindresorhus/package-directory-cli) - CLI for this package\n- [package-up](https://github.com/sindresorhus/package-up) - Find the closest package.json file\n- [find-up](https://github.com/sindresorhus/find-up) - Find a file by walking up parent directories\n","_attachments":{},"homepage":"https://github.com/sindresorhus/package-directory#readme","bugs":{"url":"https://github.com/sindresorhus/package-directory/issues"},"license":"MIT"}