A simple module that makes ignoring the node require cache easy.
Say you have a file that has slightly different behavior when running in a production environment. Like so:
var isProd = processenvNODE_ENV === 'production'if isProd// do special prod stuffelse// do non-prod stuffmoduleexports = myModule
When you require this module in your test files, it'll run the
isProd check once and then cache that version of the module. This makes it difficult to test both behaviors.
require-again allows you to get a freshly required version of the module.
Requiring the module normally after using requireAgain will return the original cached version of the module.
Example using Mocha
var requireAgain =var pathToModule = './path/to/module'
This module is tested in Node versions:
See releases for a detailed changelog.