Throw new MongooseError('Mongoose.prototype.connect() no longer accepts a callback');

1 Like

downgrade the version to 6.10.0

change your code with this;

const mongoose = require('mongoose');
const mongoURI = "mongodb://localhost:27017"

const connectToMongo = async () => {
try {
    mongoose.set('strictQuery', false)
    mongoose.connect(mongoURI) 
    console.log('Mongo connected')
}
catch(error) {
    console.log(error)
    process.exit()
}
}
module.exports = connectToMongo;

It will definitely helped.

1 Like