MongoParseError: options useCreateIndex, useFindAndModify are not supported


I tried to run it and it said an error like the title. and
this is my code:

const URI = process.env.MONGODB_URL;

mongoose.connect(URI, {
   useCreateIndex: true, 
   useFindAndModify: false, 
   useNewUrlParser: true, 
   useUnifiedTopology: true 
}, err => {
   if(err) throw err;
   console.log('Connected to MongoDB!!!')

I set the MONGODB_URL in .env :

MONGODB_URL = mongodb+srv://username:<password>

How to fix it?


From the Mongoose 6.0 docs:

useNewUrlParser, useUnifiedTopology, useFindAndModify, and useCreateIndex are no longer supported options. Mongoose 6 always behaves as if useNewUrlParser, useUnifiedTopology, and useCreateIndex are true, and useFindAndModify is false. Please remove these options from your code.


Leave a Reply

Your email address will not be published. Required fields are marked *