Colt / YelpCamp

583 stars 560 forks source link

Mongo connection error #16

Closed PrettiestRobot closed 3 years ago

PrettiestRobot commented 3 years ago

I kept receiving a notification whenever I would run nodemon telling me there was a vulnerability and suggesting I run an audit. I did and it said I should update mongoose to a new version. Ever since the update I'm getting this error and I can't start the server:

connection error: MongoParseError: options usecreateindex, usefindandmodify are not supported at Object.parseOptions (C:\Users\prett\desktop\WebDev\YelpCamp\node_modules\mongodb\lib\connection_string.js:291:15) at new MongoClient (C:\Users\prett\desktop\WebDev\YelpCamp\node_modules\mongodb\lib\mongo_client.js:62:46) at C:\Users\prett\desktop\WebDev\YelpCamp\node_modules\mongoose\lib\connection.js:779:16 at new Promise () at NativeConnection.Connection.openUri (C:\Users\prett\desktop\WebDev\YelpCamp\node_modules\mongoose\lib\connection.js:776:19) at C:\Users\prett\desktop\WebDev\YelpCamp\node_modules\mongoose\lib\index.js:330:10 at C:\Users\prett\desktop\WebDev\YelpCamp\node_modules\mongoose\lib\helpers\promiseOrCallback.js:32:5 at new Promise () at promiseOrCallback (C:\Users\prett\desktop\WebDev\YelpCamp\node_modules\mongoose\lib\helpers\promiseOrCallback.js:31:10) at Mongoose._promiseOrCallback (C:\Users\prett\desktop\WebDev\YelpCamp\node_modules\mongoose\lib\index.js:1151:10) (node:12200) UnhandledPromiseRejectionWarning: MongoParseError: options usecreateindex, usefindandmodify are not supported at Object.parseOptions (C:\Users\prett\desktop\WebDev\YelpCamp\node_modules\mongodb\lib\connection_string.js:291:15) at new MongoClient (C:\Users\prett\desktop\WebDev\YelpCamp\node_modules\mongodb\lib\mongo_client.js:62:46) at C:\Users\prett\desktop\WebDev\YelpCamp\node_modules\mongoose\lib\connection.js:779:16 at new Promise () at NativeConnection.Connection.openUri (C:\Users\prett\desktop\WebDev\YelpCamp\node_modules\mongoose\lib\connection.js:776:19) at C:\Users\prett\desktop\WebDev\YelpCamp\node_modules\mongoose\lib\index.js:330:10 at C:\Users\prett\desktop\WebDev\YelpCamp\node_modules\mongoose\lib\helpers\promiseOrCallback.js:32:5 at new Promise () at promiseOrCallback (C:\Users\prett\desktop\WebDev\YelpCamp\node_modules\mongoose\lib\helpers\promiseOrCallback.js:31:10) at Mongoose._promiseOrCallback (C:\Users\prett\desktop\WebDev\YelpCamp\node_modules\mongoose\lib\index.js:1151:10) (Use node --trace-warnings ... to show where the warning was created) (node:12200) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2) (node:12200) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejectio

PrettiestRobot commented 3 years ago

I fixed it. After a quick search on stack overflow, I needed to remove:

usecreateindex usefindandmodify

from my mongoos.connect function.