From the node.js documentation:
Modules are cached after the first time they are loaded. This means (among other things) that every call to require(\'
Yes, you can invalidate cache.
The cache is stored in an object called require.cache which you can access directly according to filenames (e.g. - /projects/app/home/index.js
as opposed to ./home
which you would use in a require('./home')
statement).
delete require.cache['/projects/app/home/index.js'];
Our team has found the following module useful. To invalidate certain groups of modules.
https://www.npmjs.com/package/node-resource