basant307/AI_Governance_Project
048
1# import-fresh2 3> Import a module while bypassing the [cache](https://nodejs.org/api/modules.html#modules_caching)4 5Useful for testing purposes when you need to freshly import a module.6 7## ESM8 9For ESM, you can use this snippet:10 11```js12const importFresh = moduleName => import(`${moduleName}?${Date.now()}`);13 14const {default: foo} = await importFresh('foo');15```16 17**This snippet causes a memory leak, so only use it for short-lived tests.**18 19## Install20 21```sh22npm install import-fresh23```24 25## Usage26 27```js28// foo.js29let i = 0;30module.exports = () => ++i;31```32 33```js34const importFresh = require('import-fresh');35 36require('./foo')();37//=> 138 39require('./foo')();40//=> 241 42importFresh('./foo')();43//=> 144 45importFresh('./foo')();46//=> 147```48 49## Related50 51- [clear-module](https://github.com/sindresorhus/clear-module) - Clear a module from the import cache52- [import-from](https://github.com/sindresorhus/import-from) - Import a module from a given path53- [import-cwd](https://github.com/sindresorhus/import-cwd) - Import a module from the current working directory54- [import-lazy](https://github.com/sindresorhus/import-lazy) - Import modules lazily55 