Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: object is not a function Node js Node Authentication

This is one of my first stack overflow questions, so I'll try to do my best in asking my question..

I'm following this tutorial exactly ( http://scotch.io/tutorials/javascript/easy-node-authentication-setup-and-local ) and after the third part ( "Application Setup server.js) when I try to run the server I get "TypeError: object is not a function" for the line:

require('./app/routes.js')(app, pspt); // load our routes and pass in our app

I found other people having similar problems that were caused by naming conflicts with local variables. I tried renaming passport to pspt but it seems like the error was found at the start of the second parenthesis, before my variables. Should I rename the 'app/routes' folder?

Thanks!

EDIT: Yeah, the tutorial made it seem like it should work right after the third part. I moved onto the fourth part and it worked fine. Thanks again.

like image 514
user2905205 Avatar asked May 07 '26 20:05

user2905205


1 Answers

Make sure your ./app/routes.js module returns a function. It should be something like:

module.exports = function(app, passport) {
    //...
};
like image 100
gfpacheco Avatar answered May 09 '26 09:05

gfpacheco