-
Notifications
You must be signed in to change notification settings - Fork 7.3k
module.parent.filename is cached. #6149
Comments
Yes, it is. The module gets evaluated only once so its parent is the module that first require()s it. |
I see... thank you! |
No. Please find another way around. Export a function, and call it with the relevant data if you care about this. |
eg: // a.js
module.exports = function(caller) {
doSomething(caller)
};
// b.js
var a = require('./a.js');
a(__filename); |
All right. thx! Initially, I thought it's possible if change the As of advice I have received from you, so i decide to give the file path. |
I ran into this unexpected behavior as well. I wish the property was called |
That last change @jakswa mentioned would be very welcome. |
Per: jorrit/node@54a7f79 Fixes: nodejs/node-v0.x-archive#6149 Originally submitted by @jorrit
Per: jorrit/node@54a7f79 Fixes: nodejs/node-v0.x-archive#6149 Originally submitted by @jorrit Reviewed By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> PR-URL: #2378
Per: jorrit/node@54a7f79 Fixes: nodejs/node-v0.x-archive#6149 Originally submitted by @jorrit Reviewed By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> PR-URL: #2378
When a file is called twice, module.parent is cached.
Is this correct behavior?
a.js
b.js
c.js
console
The text was updated successfully, but these errors were encountered: