Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

2K
Views
Error: `useFindAndModify` is an invalid option

I am new to MERN stack and I am following MERN stack tutorial on YouTube. I got an error on Mongoose.

Error: `useFindAndModify` is an invalid option

I couldn't find any solution to that.

    import express from "express";
    import bodyParser from "body-parser";
    import mongoose from "mongoose";
    import cors from "cors";


    const app = express();
    app.use(bedyParser.json({ limit: "30mb", extended: true }));
    app.use(bodyParser.urlencoded({ limit: "30mb", extended: true }));

    app.use(cors());

    const CONNECTION_URL =
    "mongodb+srv://myratcharyyev:<password>@clustero.mn9xi.mongodb.net/myFirstDatabase?retryWrites=true&w=majority";
    const PORT = process.env.PORT || 5000;
    mongoose
    .connect(CONNECTION_URL, {
    useNewUrlParser: true,
    useUnifiedTopology: true
    // useCreateIndex: true
    })
    .then(( =>
    app.listen (PORT, () => console.log("Server running on port: ${PORT}'))
    )
    .catch((error) => console.log(error message));
    mongoose.set("useFindAndModify", false);
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

You are explicitly setting useFindAndModify with .set(). Remove the line below:

mongoose.set("useFindAndModify", false);
over 4 years ago · Santiago Trujillo Report

0

It's a deprecated now. // No longer necessary:

mongoose.set('useFindAndModify', false);

await mongoose.connect('mongodb://localhost:27017/test', {
  useNewUrlParser: true, // <-- no longer necessary
  useUnifiedTopology: true // <-- no longer necessary
});

use this line of code

mongoose.connect(CONNECTION_URL).then(()=>{console.log('...')})

https://mongoosejs.com/docs/migrating_to_6.html#mongoose-connect-returns-a-promise

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!