decache is a lightweight utility (v4.6.2, stable, low maintenance) that deletes a module from Node.js require.cache, enabling fresh require() calls for testing or hot-reloading. It works with .js, .json, and other extensions, but ignores native .node modules. Unlike alternatives that require hacking require.cache directly, decache handles edge cases (e.g., parent module references) and includes TypeScript definitions. Released under MIT, with a small footprint and no dependencies.
npm install decacheNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates decaching a module and re-requiring it to get a fresh copy.
Do not rely on decache for native modules; unload them manually if needed.
Ensure no other module depends on the cached instance you are deleting.
Use import decache from 'decache' in ESM or const decache = require('decache') in CJS.Run: npm install decache --save-dev
Use: import decache from 'decache' or const decache = require('decache')Require the module first, then decache it.
No dependency data recorded yet.