dimanche 28 décembre 2014

Node.js Require Module that Requires Module [duplicate]



This question already has an answer here:




Can I require a module that requires the requiring module?



//a.js
a = {
bar: function (){ return "foobar"}
}
b = require('./b.js');
a.b = b;
a.b.foo





//b.js
a = require('./a.js');
b{
foo: function () {return a.bar + "b";}
}


In this case there isn't infinite recursion. I tried doing it in my node.js project, but a kept on coming out as an empty object {}... Why?





Aucun commentaire:

Enregistrer un commentaire