I got an error while connecting nodejs app to mongo cluster

const mongoose = require("mongoose");
mongoose.connect("mongodb+srv://u:p@cluster0.xxxxxx.mongodb.net/cooking_Blog?retryWrites=true&w=majority", {useNewUrlParser:true, useUnifiedTopology:true}).then(()=>{
    console.log("connected sucessfully");
    console.log("error connection failed");

and I got this error:

        for (let i = 0; i < error.writeErrors.length; ++i) {

TypeError: Cannot read properties of undefined (reading 'length')
    at E:\projects\recipies_website\node_modules\mongoose\lib\model.js:3198:47

Node.js v19.7.0

Hey @Vikash_Sharma,

Thank you for reaching out to the MongoDB Community forums.

I tested your code and it worked flawlessly for me using node v19.7.0.

Would it be possible for you to provide the complete code snippet and the version of Mongoose you are using? I suspect that the problem may be related to something else.

Best regards,