Open jeeemmyy opened 3 years ago
I think you need to give the name of the database as well. I am fairly new as well, but I don't see any database name given here, so the function does not know which database to connect to. That might be the problem I think. Please check and give the name of the database like mongodb://localhost:27017/"name your database here"/?readPreference=primary&appname=MongoDB%20Compass&ssl=false I think this should work. Please give it a try and let me know if it solves your issues. Again, I am also a beginner so this might not work.
This is the error i am getting. Would like to know what wrong am i doing.
My URI from Local MongoDB Compass is:
mongodb://localhost:27017/?readPreference=primary&appname=MongoDB%20Compass&ssl=false
But code is not accepting it & instead throwing this error.### ERROR:
Server running on 5000 (node:23032) Warning: Accessing non-existent property 'count' of module exports inside circular dependency
(Use node --trace-warnings ...` to show where the warning was created) (node:23032) Warning: Accessing non-existent property 'findOne' of module exports inside circular dependency
(node:23032) Warning: Accessing non-existent property 'remove' of module exports inside circular dependency
(node:23032) Warning: Accessing non-existent property 'updateOne' of module exports inside circular dependency D:\06 - University\FYP\Hassan\node_passport_login-master\node_modules\mongodb\lib\operations\db_ops.js:549 throw MongoError.create({ message: 'database name must be a string', driver: true }); ^
MongoError: database name must be a string at Function.create (D:\06 - University\FYP\Hassan\node_passport_login-master\node_modules\mongodb\lib\core\error.js:44:12) at validateDatabaseName (D:\06 - University\FYP\Hassan\node_passport_login-master\node_modules\mongodb\lib\operations\db_ops.js:549:22) at new Db (D:\06 - University\FYP\Hassan\node_passport_login-master\node_modules\mongodb\lib\db.js:190:3) at MongoClient.db (D:\06 - University\FYP\Hassan\node_passport_login-master\node_modules\mongodb\lib\mongo_client.js:275:14) at D:\06 - University\FYP\Hassan\node_passport_login-master\node_modules\mongoose\lib\connection.js:638:62 at D:\06 - University\FYP\Hassan\node_passport_login-master\node_modules\mongodb\lib\operations\execute_operation.js:75:17 at executeCallback (D:\06 - University\FYP\Hassan\node_passport_login-master\node_modules\mongodb\lib\operations\execute_operation.js:68:9) at D:\06 - University\FYP\Hassan\node_passport_login-master\node_modules\mongodb\lib\operations\connect.js:193:7 at connectCallback (D:\06 - University\FYP\Hassan\node_passport_login-master\node_modules\mongodb\lib\operations\connect.js:340:5) at D:\06 - University\FYP\Hassan\node_passport_login-master\node_modules\mongodb\lib\operations\connect.js:472:7 at Server.connectHandler (D:\06 - University\FYP\Hassan\node_passport_login-master\node_modules\mongodb\lib\core\sdam\topology.js:259:45) at Object.onceWrapper (events.js:422:26) at Server.emit (events.js:327:22) at Pool. (D:\06 - University\FYP\Hassan\node_passport_login-master\node_modules\mongodb\lib\core\sdam\server.js:470:12)
at Pool.emit (events.js:315:20)
at D:\06 - University\FYP\Hassan\node_passport_login-master\node_modules\mongodb\lib\core\connection\pool.js:624:10 {
driver: true,
} npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! node_passport_login@2.0.0 start:
node app.js
npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the node_passport_login@2.0.0 start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\Dell\AppData\Roaming\npm-cache_logs\2021-08-10T18_19_25_135Z-debug.log`