### Install package-directory via npm Source: https://github.com/sindresorhus/package-directory/blob/main/readme.md Instructions to install the 'package-directory' package using the npm package manager. ```sh npm install package-directory ``` -------------------------------- ### package-directory API Reference Source: https://github.com/sindresorhus/package-directory/blob/main/readme.md Detailed API documentation for the `packageDirectory` and `packageDirectorySync` functions, including their parameters, return types, and available options for customizing the search. ```APIDOC packageDirectory(option?) Returns: Promise Description: Returns a Promise for either the project root path or undefined if it could not be found. packageDirectorySync(options?) Returns: string | undefined Description: Returns the project root path or undefined if it could not be found. options Type: object Properties: cwd Type: string Default: process.cwd() Description: The directory to start searching from. ``` -------------------------------- ### Find Node.js project root asynchronously with packageDirectory Source: https://github.com/sindresorhus/package-directory/blob/main/readme.md Demonstrates how to use the asynchronous `packageDirectory` function to find the root directory of a Node.js project. It returns a Promise that resolves to the path of the directory containing the closest package.json file, or `undefined` if not found. ```js import {packageDirectory} from 'package-directory'; console.log(await packageDirectory()); //=> '/Users/sindresorhus/foo' ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.