Skip to content

Instantly share code, notes, and snippets.

@insomniac-xt
Last active February 14, 2023 00:44
Show Gist options
  • Save insomniac-xt/00b8400fb7cb875bb973 to your computer and use it in GitHub Desktop.
Save insomniac-xt/00b8400fb7cb875bb973 to your computer and use it in GitHub Desktop.
Node.js require force reload
var requireReload = function(modulePath){
delete require.cache[require.resolve(modulePath)];
return require(modulePath);
};
@Eomm
Copy link

Eomm commented Jan 25, 2022

function cleanCache () {
  Object.keys(require.cache).forEach(function (key) { delete require.cache[key] })
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment