Talk:Modules

Module Scope
While it is documented, its important to note two critical features of modules: For example: if you create a module "Foo" module.exports= { tags: [] }
 * 1) The object that is returned by require is the same no matter where you call it from.
 * 2) A given module loads only once and cannot be reloaded or purged.

...then added a tag to it in one file var foo = require('foo'); foo.tags.push('a');

...then added a tag to it in another file, and echo the result var foo = require('foo'); foo.tags.push('b'); console.log(foo.tags); The result is ['a', 'b'], and will be whenever the foo module is required until the node process is shut down.

Reloading Modules (can't be done)
As nice as it would be to be able to "hot swap" a module after its loaded when you want to upgrade your codebase this simply isn't something that can be done in Node.

Until you shut a running Node application down, once a module has been loaded it will persiste in memory until shutdown.