I have a js file like this
loader.js
exports.getConfig = function() {
return config;
}
I am loading this file in other file as
var loader = require(__dirname + '/../../loader');
var config = loader.getConfig();
But I am getting error as Object has no method getCOnfig() I checked the path the path in require is correct
Maybe you have made a circular require, it's not obvious,check it carefully:
If yes,learn more: https://coderwall.com/p/myzvmg
I say circular require,I mean suppose you have three module A,B,C. A require B,B require C,C require A. Yes,this is a circular require,this may cause strange error.
I don't know why somebody downvote my answer, I spent hours to figure out what happened when I get this error.I think this question probably is a circular require situation.