Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including decache with all npm packages installed. Try it out:

var decache = require("decache")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

decache v4.5.1

decache (Delete Cache) lets you delete modules from node.js require() cache; useful when testing your modules/projects.


Delete a module from node.js' require.cache so you can freshly require it again.

Build Status Code Climate maintainability Dependencies Status devDependencies Status contributions welcome HitCount

In node.js when you require() a module, node stores a cached version of the module, so that all subsequent calls to require() do not have to reload the module from the filesystem.

decache ( Delete Cache ) lets you delete modules from node.js require() 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:
var decache = require('decache');

// require a module that you wrote"
var 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:

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

Modules other than .js, like for example, .jsx, are supported as well.

Note that native modules with the .node 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:


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free