\begin{quote}
Find the module object for something that was require()d \end{quote}
\href{https://travis-ci.org/nexdrew/which-module}{\texttt{ }} \href{https://coveralls.io/github/nexdrew/which-module?branch=master}{\texttt{ }} \href{https://github.com/conventional-changelog/standard-version}{\texttt{ }}

Find the {\ttfamily module} object in {\ttfamily require.\+cache} for something that was {\ttfamily require()}d or {\ttfamily import}ed -\/ essentially a reverse {\ttfamily require()} lookup.

Useful for libs that want to e.\+g. lookup a filename for a module or submodule that it did not {\ttfamily require()} itself.\hypertarget{md_sfcode_node_modules_which_module_README_autotoc_md34092}{}\doxysection{Install and Usage}\label{md_sfcode_node_modules_which_module_README_autotoc_md34092}

\begin{DoxyCode}{0}
\DoxyCodeLine{npm install -\/-\/save which-\/module }

\end{DoxyCode}



\begin{DoxyCode}{0}
\DoxyCodeLine{const whichModule = require('which-\/module')}
\DoxyCodeLine{}
\DoxyCodeLine{console.log(whichModule(require('something')))}
\DoxyCodeLine{// Module \{}
\DoxyCodeLine{//   id: '/path/to/project/node\_modules/something/index.js',}
\DoxyCodeLine{//   exports: [Function],}
\DoxyCodeLine{//   parent: ...,}
\DoxyCodeLine{//   filename: '/path/to/project/node\_modules/something/index.js',}
\DoxyCodeLine{//   loaded: true,}
\DoxyCodeLine{//   children: [],}
\DoxyCodeLine{//   paths: [ '/path/to/project/node\_modules/something/node\_modules',}
\DoxyCodeLine{//            '/path/to/project/node\_modules',}
\DoxyCodeLine{//            '/path/to/node\_modules',}
\DoxyCodeLine{//            '/path/node\_modules',}
\DoxyCodeLine{//            '/node\_modules' ] \} }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_which_module_README_autotoc_md34093}{}\doxysection{API}\label{md_sfcode_node_modules_which_module_README_autotoc_md34093}
\hypertarget{md_sfcode_node_modules_which_module_README_autotoc_md34094}{}\doxysubsection{$<$tt$>$which\+Module(exported)$<$/tt$>$}\label{md_sfcode_node_modules_which_module_README_autotoc_md34094}
Return the \href{https://nodejs.org/api/modules.html\#modules_the_module_object}{\texttt{ {\ttfamily module} object}}, if any, that represents the given argument in the {\ttfamily require.\+cache}.

{\ttfamily exported} can be anything that was previously {\ttfamily require()}d or {\ttfamily import}ed as a module, submodule, or dependency -\/ which means {\ttfamily exported} is identical to the {\ttfamily module.\+exports} returned by this method.

If {\ttfamily exported} did not come from the {\ttfamily exports} of a {\ttfamily module} in {\ttfamily require.\+cache}, then this method returns {\ttfamily null}.\hypertarget{md_sfcode_node_modules_which_module_README_autotoc_md34095}{}\doxysection{License}\label{md_sfcode_node_modules_which_module_README_autotoc_md34095}
ISC © Contributors 