$ gnpm install clear-module
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()
.
Copyright 2013 - present © cnpmjs.org | Home |