Gemma Blackgemmablack.dev·Nov 17, 2024Node.js: using fs.watch to re-import CommonJS modules.Disclaimer. This is an investigation into what is possible. Not a fully-blown solution into how to reload modules without restarting the whole server. In a previous article, I was investigating how to use require.cache to refresh a module by deletin...Discussfs.watch
Gemma Blackgemmablack.dev·Nov 17, 2024Node.js: refreshing a module using require.cacheThis is purely in reference to CommonJS modules. TLDR Before I bore you with why I did this, refreshing a module can be done by deleting its reference in the require.cache object. Like so: require('./some-module') // use module delete require.cach...Discussrequire.cache