How do I get the dirname of the calling method when it is in a different file in nodejs?
Use callsite, then:
b.js:
var path = require('path'),
callsite = require('callsite');
module.exports = {
someFn: function () {
var stack = callsite(),
requester = stack[1].getFileName();
console.log(path.dirname(requester));
}
};