I don't think you can do hot swapping while running a node.js application.
Node.js keeps the require
d module in cache during the lifetime of the application. However, you can do something like
delete require.cache[require.resolve('./module.js')]
Or if you want to reload all the modules, then
for (var key in require.cache) {
delete require.cache[key];
}
This will delete the cached key from require
cache and force node.js to reload the module next time when require('./module.js')
occurs.