Every module injected only once

suggest change

NodeJS executes the module only the first time you require it. Any further require functions will re-use the same Object, thus not executing the code in the module another time. Also Node caches the modules first time they are loaded using require. This reduces the number of file reads and helps to speed up the application.

myModule.js

console.log(123) ; 
exports.var1 = 4 ;

index.js

var a=require('./myModule') ; // Output 123
var b=require('./myModule') ; // No output
console.log(a.var1) ; // Output 4
console.log(b.var1) ; // Output 4
a.var2 = 5 ; 
console.log(b.var2) ; // Output 5

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Exporting and consuming modules:
* Every module injected only once

Table Of Contents
1 npm
4 Exporting and consuming modules
41 cli
43 grunt
59 Hack
64 ES6
67 Redis
69 MongoDB
86 MongoDB
87 Lodash
91 CORS
105 N-API
108 Require