Need help with decache?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

135 Stars 15 Forks 87 Commits 9 Opened issues


:shipit: Delete Cached node_modules useful when you need to "un-require" during testing for a fresh state.

Services available


Need anything else?

Contributors list


Delete a module from node.js'

so you can freshly
it again.

GitHub Workflow Status Code Climate maintainability dependency status contributions welcome HitCount

In node.js when you

a module, node stores a cached version of the module, so that all subsequent calls to
do not have to reload the module from the filesystem.

( Delete Cache ) lets you delete modules from node.js
cache this is useful when testing your modules/projects.


When testing our modules we often need to re-require the module being tested. This makes it easy.


An easy way to delete a cached module.

How? (usage)


Install the module from npm:

npm install decache --save-dev

Use it in your code:

// require the decache module:
const decache = require('decache');

// require a module that you wrote" let mymod = require('./mymodule.js');

// use your module the way you need to: console.log(mymod.count()); // 0 (the initial state for our counter is zero) console.log(mymod.incrementRunCount()); // 1

// delete the cached module: decache('./mymodule.js');

// mymod = require('./mymodule.js'); // fresh start console.log(mymod.count()); // 0 (back to initial state ... zero)

Modules other than

, like for example,
, are supported as well.

Note that native modules with the

extension are ignored from decaching because they behave unexpectedly when decached.

If you have any questions or need more examples, please create a GitHub issue:


We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.