MongoDB and Mongoose - Install and Set Up Mongoose

test cases getting failed:
// running tests
“mongoose version ^5.11.15” dependency should be in package.json
“mongoose” should be connected to a database
// tests completed
// console output
[Error: Not Found]
[Error: Not Found]

this is myApp.js file:
const mongoose = require(‘mongoose’)
mongoose.connect(‘mongodb+srv://’,{ useNewUrlParser: true, useUnifiedTopology: true }).then((resolve) => {
console.log(“connected successfully!”)
}).catch((error) => {

My repl link:

Well, the first error says you’re running the wrong version of mongoose.

Change your dependency in package.json to match what the message is saying you need (version ^5.11.15), and then you can run npm i again to ensure it’s installed.

Also make sure you’re properly adding your mongo URL, and if using a .env or Secret, that this is properly setup.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.