Tiny and zero dependencies utility, that finds the root of npm project.
npm install @ambiere/project-root
Example npm project structure:
/
└── root
├── .git
├── package.json
└── src
├── types
└── index.js
Find the root of the project in index.js
file:
import projectRootDir from "@ambiere/project-root"
const projectRoot = projectRootDir()
console.log(projectRoot) // → /root
Return the root directory of the npm project or undefined
if none could be found.
Type: string
Default: process.cwd
The directory to start the search.