\begin{quote}
Find the root directory of a Node.\+js project or npm package \end{quote}
\hypertarget{md_sfcode_node_modules_find_cache_dir_node_modules_pkg_dir_readme_autotoc_md10734}{}\doxysection{Install}\label{md_sfcode_node_modules_find_cache_dir_node_modules_pkg_dir_readme_autotoc_md10734}

\begin{DoxyCode}{0}
\DoxyCodeLine{\$ npm install pkg-\/dir }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_find_cache_dir_node_modules_pkg_dir_readme_autotoc_md10735}{}\doxysection{Usage}\label{md_sfcode_node_modules_find_cache_dir_node_modules_pkg_dir_readme_autotoc_md10735}

\begin{DoxyCode}{0}
\DoxyCodeLine{/}
\DoxyCodeLine{└── Users}
\DoxyCodeLine{    └── sindresorhus}
\DoxyCodeLine{        └── foo}
\DoxyCodeLine{            ├── package.json}
\DoxyCodeLine{            └── bar}
\DoxyCodeLine{                ├── baz}
\DoxyCodeLine{                └── example.js }

\end{DoxyCode}



\begin{DoxyCode}{0}
\DoxyCodeLine{// example.js}
\DoxyCodeLine{const pkgDir = require('pkg-\/dir');}
\DoxyCodeLine{}
\DoxyCodeLine{(async () => \{}
\DoxyCodeLine{    const rootDir = await pkgDir(\_\_dirname);}
\DoxyCodeLine{}
\DoxyCodeLine{    console.log(rootDir);}
\DoxyCodeLine{    //=> '/Users/sindresorhus/foo'}
\DoxyCodeLine{\})(); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_find_cache_dir_node_modules_pkg_dir_readme_autotoc_md10736}{}\doxysection{API}\label{md_sfcode_node_modules_find_cache_dir_node_modules_pkg_dir_readme_autotoc_md10736}
\hypertarget{md_sfcode_node_modules_find_cache_dir_node_modules_pkg_dir_readme_autotoc_md10737}{}\doxysubsection{pkg\+Dir(\mbox{[}cwd\mbox{]})}\label{md_sfcode_node_modules_find_cache_dir_node_modules_pkg_dir_readme_autotoc_md10737}
Returns a {\ttfamily Promise} for either the project root path or {\ttfamily undefined} if it couldn\textquotesingle{}t be found.\hypertarget{md_sfcode_node_modules_find_cache_dir_node_modules_pkg_dir_readme_autotoc_md10738}{}\doxysubsection{pkg\+Dir.\+sync(\mbox{[}cwd\mbox{]})}\label{md_sfcode_node_modules_find_cache_dir_node_modules_pkg_dir_readme_autotoc_md10738}
Returns the project root path or {\ttfamily undefined} if it couldn\textquotesingle{}t be found.\hypertarget{md_sfcode_node_modules_find_cache_dir_node_modules_pkg_dir_readme_autotoc_md10739}{}\doxysubsubsection{cwd}\label{md_sfcode_node_modules_find_cache_dir_node_modules_pkg_dir_readme_autotoc_md10739}
Type\+: {\ttfamily string}~\newline
 Default\+: {\ttfamily process.\+cwd()}

Directory to start from.\hypertarget{md_sfcode_node_modules_find_cache_dir_node_modules_pkg_dir_readme_autotoc_md10740}{}\doxysection{Related}\label{md_sfcode_node_modules_find_cache_dir_node_modules_pkg_dir_readme_autotoc_md10740}

\begin{DoxyItemize}
\item \href{https://github.com/sindresorhus/pkg-dir-cli}{\texttt{ pkg-\/dir-\/cli}} -\/ CLI for this module
\item \href{https://github.com/sindresorhus/pkg-up}{\texttt{ pkg-\/up}} -\/ Find the closest package.\+json file
\item \href{https://github.com/sindresorhus/find-up}{\texttt{ find-\/up}} -\/ Find a file by walking up parent directories
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_find_cache_dir_node_modules_pkg_dir_readme_autotoc_md10741}{}\doxysection{License}\label{md_sfcode_node_modules_find_cache_dir_node_modules_pkg_dir_readme_autotoc_md10741}
MIT © \href{https://sindresorhus.com}{\texttt{ Sindre Sorhus}} 