I want to use one module feature within another module
file main.js
var _ = require("./underscore.js");
var foo = require("./bar.js");
foo.publish(...);
file bar.js
(function(e) {
var array = [...];
e.publish = function(t, args) {
_.each(array, function(...) {...});
});
})(exports);
I've tried a couple of variations, but I am not sure of the best way around this error:
ReferenceError: _ is not defined
var _ = require("./underscore.js");to your bar.js aswell._in both "main.js" and "bar.js" I am considering which solution is better: Vyacheslav Voronchuk's (passing in_), or yours (require in two places).