You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First call require load file from filesystem, second call get this file from cache (reference on object). But my function(s) may be change this object. And second call require return changed object. It is normal behavior or not?
If you want a module to export a default state that multiple things can get unique copies of, you can export a function that you can call to return a new instance of the object.
Activity
Fishrock123 commentedon Oct 16, 2015
This is normal behavior.
require()caches.If you need to re-read it you'll need to use the
fs module, probablyfs.readFileSync(), though that won't be very efficient.Qard commentedon Oct 16, 2015
If you want a module to export a default state that multiple things can get unique copies of, you can export a function that you can call to return a new instance of the object.
Rather than this:
Do this: