Connection to MongoDB database no passing test

Tell us what’s happening:
I cannot seem to pass the third test on the first challenge of MongoDB and Mongoose. Keeps on saying ’ “mongoose” should be connected to a database’. However I can see an active connection on the MongoDB Atlas database. Anyone experiencing the same issue or able to assist?

Your project link(s)


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36

Challenge: Install and Set Up Mongoose

Link to the challenge:

Do you get any errors in the repl console? If not, can you try:

// add this line:
mongoose.connection.on('connected', () => console.log('connected'))

If your database is successfully connected, it should output "connected" to the console.

I have tried and there is nothing on the console.

I have this error on the console : “(node:754) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see Command-line options | Node.js v16.9.1 Documentation). (rejection id: 1)
(node:754) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.”

There is also this "warning " in the editor which I do not understand: "[typescript]
Could not find a declaration file for module ‘mongoose’. ‘/home/runner/boilerplate-mongomongoose/node_modules/mongoose/index.js’ implicitly has an ‘any’ type.
Try npm install @types/mongoose if it exists or add a new declaration (.d.ts) file containing declare module 'mongoose';"

I have added mongoose onto the package manager. I really don’t understand what the issue is.

And you have set your MONGO_URI in the Secrets tab? Does it look something like this: mongodb+srv://<username>:<password><database_name>?retryWrites=true&w=majority ?

Thanks for all the help. The URI was not the problem.

I have deleted the old Replit, loaded a new Replit starter but this time I added the required dependencies via the “search to install package”. They also seem to be of higher versions that the ones required on the challenge. It worked :slight_smile:

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