Skip to content

Instantly share code, notes, and snippets.

@phucpnt
Forked from adam-lynch/requireNoCache.js
Created July 9, 2016 02:36
Show Gist options
  • Save phucpnt/98618f9f2be41d29833f69bc28d51826 to your computer and use it in GitHub Desktop.
Save phucpnt/98618f9f2be41d29833f69bc28d51826 to your computer and use it in GitHub Desktop.
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);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment