\begin{quote}
Resolve the path of a module like \href{https://nodejs.org/api/globals.html\#globals_require_resolve}{\texttt{ {\ttfamily require.\+resolve()}}} but from a given path \end{quote}
\hypertarget{md_sfcode_node_modules_resolve_from_readme_autotoc_md24386}{}\doxysection{Install}\label{md_sfcode_node_modules_resolve_from_readme_autotoc_md24386}

\begin{DoxyCode}{0}
\DoxyCodeLine{\$ npm install -\/-\/save resolve-\/from }

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

\begin{DoxyCode}{0}
\DoxyCodeLine{const resolveFrom = require('resolve-\/from');}
\DoxyCodeLine{}
\DoxyCodeLine{// There is a file at `./foo/bar.js`}
\DoxyCodeLine{}
\DoxyCodeLine{resolveFrom('foo', './bar');}
\DoxyCodeLine{//=> '/Users/sindresorhus/dev/test/foo/bar.js' }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_resolve_from_readme_autotoc_md24388}{}\doxysection{API}\label{md_sfcode_node_modules_resolve_from_readme_autotoc_md24388}
\hypertarget{md_sfcode_node_modules_resolve_from_readme_autotoc_md24389}{}\doxysubsection{resolve\+From(from\+Dir, module\+Id)}\label{md_sfcode_node_modules_resolve_from_readme_autotoc_md24389}
Like {\ttfamily require()}, throws when the module can\textquotesingle{}t be found.\hypertarget{md_sfcode_node_modules_resolve_from_readme_autotoc_md24390}{}\doxysubsection{resolve\+From.\+silent(from\+Dir, module\+Id)}\label{md_sfcode_node_modules_resolve_from_readme_autotoc_md24390}
Returns {\ttfamily null} instead of throwing when the module can\textquotesingle{}t be found.\hypertarget{md_sfcode_node_modules_resolve_from_readme_autotoc_md24391}{}\doxysubsubsection{from\+Dir}\label{md_sfcode_node_modules_resolve_from_readme_autotoc_md24391}
Type\+: {\ttfamily string}

Directory to resolve from.\hypertarget{md_sfcode_node_modules_resolve_from_readme_autotoc_md24392}{}\doxysubsubsection{module\+Id}\label{md_sfcode_node_modules_resolve_from_readme_autotoc_md24392}
Type\+: {\ttfamily string}

What you would use in {\ttfamily require()}.\hypertarget{md_sfcode_node_modules_resolve_from_readme_autotoc_md24393}{}\doxysection{Tip}\label{md_sfcode_node_modules_resolve_from_readme_autotoc_md24393}
Create a partial using a bound function if you want to resolve from the same {\ttfamily from\+Dir} multiple times\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{const resolveFromFoo = resolveFrom.bind(null, 'foo');}
\DoxyCodeLine{}
\DoxyCodeLine{resolveFromFoo('./bar');}
\DoxyCodeLine{resolveFromFoo('./baz'); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_resolve_from_readme_autotoc_md24394}{}\doxysection{Related}\label{md_sfcode_node_modules_resolve_from_readme_autotoc_md24394}

\begin{DoxyItemize}
\item \href{https://github.com/sindresorhus/resolve-cwd}{\texttt{ resolve-\/cwd}} -\/ Resolve the path of a module from the current working directory
\item \href{https://github.com/sindresorhus/req-from}{\texttt{ req-\/from}} -\/ Require a module from a given path
\item \href{https://github.com/sindresorhus/req-cwd}{\texttt{ req-\/cwd}} -\/ Require a module from the current working directory
\item \href{https://github.com/sindresorhus/resolve-pkg}{\texttt{ resolve-\/pkg}} -\/ Resolve the path of a package regardless of it having an entry point
\item \href{https://github.com/sindresorhus/lazy-req}{\texttt{ lazy-\/req}} -\/ Require modules lazily
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_resolve_from_readme_autotoc_md24395}{}\doxysection{License}\label{md_sfcode_node_modules_resolve_from_readme_autotoc_md24395}
MIT © \href{https://sindresorhus.com}{\texttt{ Sindre Sorhus}} 