require-again

JSON →
library 2.0.0 ·javascript maintenance
verified Jun 7, 2026

require-again is a lightweight Node.js utility that clears the require cache for a given module path, allowing you to re-require it with fresh state. This is particularly useful in unit tests where you need to test code that behaves differently based on environment variables or other runtime conditions (e.g., NODE_ENV). The package is version 2.0.0, last updated with support for Node.js 4-6. Unlike other cache-busting tools (like decache or rerand), require-again re-adds the module back to the cache after re-requiring, so subsequent normal requires return the cached version. It has zero dependencies and a minimal API.