Clear a module from the cache
Useful for testing purposes when you need to freshly import a module.
npm install clear-module
// foo.js let i = 0; module.exports = () => ++i;
const clearModule = require('clear-module'); require('./foo')(); //=> 1 require('./foo')(); //=> 2 clearModule('./foo'); require('./foo')(); //=> 1
Type: string
What you would use with require().
Clear all modules from the cache.
Clear all matching modules from the cache.
Type: RegExp
Regex to match against the module IDs.
Clear a single module from the cache non-recursively. No parent or children modules will be affected.
This is mostly only useful if you use singletons, where you would want to clear a specific module without causing any side effects.
Type: string
What you would use with require().
- import-fresh - Import a module while bypassing the cache
- import-from - Import a module from a given path
- import-cwd - Import a module from the current working directory
- import-lazy - Import a module lazily