nodejs / help

:sparkles: Need help with Node.js? File an Issue here. :rocket:
1.47k stars 282 forks source link

TypeError: Cannot read property 'findOne' of undefined #2057

Closed ivomofor closed 4 years ago

ivomofor commented 5 years ago

I am having this issue on Node js ( TypeError: Cannot read property 'findOne' of undefined ) when i make a query to MongoDB using mongoose "User.findOne({object: 'value'})" and i am currently using Node version 10.16.0 and npm version 6.9.0. I need help on how to fix it. Thanks

Server Listening on port: 4000 -> Press Ctrl to TERMINATE! Connected to Database... TypeError: Cannot read property 'findOne' of undefined at Strategy.passport.use.localStrategy [as _verify] (C:\Users\itzme\Documents\kids\config\passport.js:9:18) at Strategy.authenticate (C:\Users\itzme\Documents\kids\node_modules\passport-local\lib\strategy.js:90:12) at attempt (C:\Users\itzme\Documents\kids\node_modules\passport\lib\middleware\authenticate.js:361:16) at authenticate (C:\Users\itzme\Documents\kids\node_modules\passport\lib\middleware\authenticate.js:362:7) at router.post (C:\Users\itzme\Documents\kids\routes\signin.js:14:7) at Layer.handle [as handle_request] (C:\Users\itzme\Documents\kids\node_modules\express\lib\router\layer.js:95:5) at next (C:\Users\itzme\Documents\kids\node_modules\express\lib\router\route.js:137:13) at Route.dispatch (C:\Users\itzme\Documents\kids\node_modules\express\lib\router\route.js:112:3) at Layer.handle [as handle_request] (C:\Users\itzme\Documents\kids\node_modules\express\lib\router\layer.js:95:5) at C:\Users\itzme\Documents\kids\node_modules\express\lib\router\index.js:281:22 at Function.process_params (C:\Users\itzme\Documents\kids\node_modules\express\lib\router\index.js:335:12) at next (C:\Users\itzme\Documents\kids\node_modules\express\lib\router\index.js:275:10) at Function.handle (C:\Users\itzme\Documents\kids\node_modules\express\lib\router\index.js:174:3) at router (C:\Users\itzme\Documents\kids\node_modules\express\lib\router\index.js:47:12) at Layer.handle [as handle_request] (C:\Users\itzme\Documents\kids\node_modules\express\lib\router\layer.js:95:5) at trim_prefix (C:\Users\itzme\Documents\kids\node_modules\express\lib\router\index.js:317:13)

gireeshpunathil commented 4 years ago

@ivomofor - is this still pening?

can you show your code around User.findOne({object: 'value'}) ? How is User object created?

PoojaDurgad commented 4 years ago

@ivomofor , is this issue resolved?

gireeshpunathil commented 4 years ago

inactive, closing