I think this means that module.exports
in your ./app/routes
module is not assigned to be a function so therefore require('./app/routes')
does not resolve to a function so therefore, you cannot call it as a function like this require('./app/routes')(app, passport)
.
Show us ./app/routes
if you want us to comment further on that.
It should look something like this;
module.exports = function(app, passport) {
// code here
}
You are exporting a function that can then be called like require('./app/routes')(app, passport)
.
One other reason a similar error could occur is if you have a circular module dependency where module A is trying to require(B)
and module B is trying to require(A)
. When this happens, it will be detected by the require()
sub-system and one of them will come back as null
and thus trying to call that as a function will not work. The fix in that case is to remove the circular dependency, usually by breaking common code into a third module that both can separately load though the specifics of fixing a circular dependency are unique for each situation.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…