Skip to content

Instantly share code, notes, and snippets.

@adam-lynch
adam-lynch / requireNoCache.js
Last active April 12, 2025 08:46
Require a module, without going to Node.js's require cache
var path = require('path');
var _invalidateRequireCacheForFile = function(filePath){
delete require.cache[path.resolve(filePath)];
};
var requireNoCache = function(filePath){
_invalidateRequireCacheForFile(filePath);
return require(filePath);
};