\begin{quote}
Import a module while bypassing the \href{https://nodejs.org/api/modules.html\#modules_caching}{\texttt{ cache}} \end{quote}
Useful for testing purposes when you need to freshly import a module.\hypertarget{md_sfcode_node_modules_import_fresh_readme_autotoc_md12676}{}\doxysection{Install}\label{md_sfcode_node_modules_import_fresh_readme_autotoc_md12676}

\begin{DoxyCode}{0}
\DoxyCodeLine{\$ npm install -\/-\/save import-\/fresh }

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

\begin{DoxyCode}{0}
\DoxyCodeLine{// foo.js}
\DoxyCodeLine{let i = 0;}
\DoxyCodeLine{module.exports = () => ++i; }

\end{DoxyCode}



\begin{DoxyCode}{0}
\DoxyCodeLine{const importFresh = require('import-\/fresh');}
\DoxyCodeLine{}
\DoxyCodeLine{require('./foo')();}
\DoxyCodeLine{//=> 1}
\DoxyCodeLine{}
\DoxyCodeLine{require('./foo')();}
\DoxyCodeLine{//=> 2}
\DoxyCodeLine{}
\DoxyCodeLine{importFresh('./foo')();}
\DoxyCodeLine{//=> 1}
\DoxyCodeLine{}
\DoxyCodeLine{importFresh('./foo')();}
\DoxyCodeLine{//=> 1 }

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

\begin{DoxyItemize}
\item \href{https://github.com/sindresorhus/clear-module}{\texttt{ clear-\/module}} -\/ Clear a module from the import cache
\item \href{https://github.com/sindresorhus/import-from}{\texttt{ import-\/from}} -\/ Import a module from a given path
\item \href{https://github.com/sindresorhus/import-cwd}{\texttt{ import-\/cwd}} -\/ Import a module from the current working directory
\item \href{https://github.com/sindresorhus/import-lazy}{\texttt{ import-\/lazy}} -\/ Import modules lazily
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_import_fresh_readme_autotoc_md12679}{}\doxysection{License}\label{md_sfcode_node_modules_import_fresh_readme_autotoc_md12679}
MIT © \href{https://sindresorhus.com}{\texttt{ Sindre Sorhus}} 