Require a Node module and immediately delete it from the module cache, forcing re-evaluation on the next require call. v1.0.1 is the latest stable version (no updates since 2017). Useful for testing scenarios where you need fresh module state (e.g., random values, mutable singletons). Key differentiator: lightweight and focused solely on cache eviction, unlike heavier testing utilities. Works with Node >=6, CommonJS only.
npm install require-and-forgetNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates forcing re-evaluation of a module by removing it from cache after each require.
Use dynamic import() if you need ESM-like behavior, but caching behavior differs.
If you want to keep the module cached, use regular require() instead.
Use paths as you would with require().
Ensure the path is relative to the calling file (not the module's directory) and the file exists.
Use const forget = require('require-and-forget');No dependency data recorded yet.