Mongoose not connecting

Hi all,
I followed all thte step but still having errors on the console and not able to connect mongoose :frowning:
please , note that mongodb pages tell me to edit the password AND the project in the URI whereas FCC page tells me to edit ONLY the password

Your project link(s)

solution: https://replit.com/@ranran2121/boilerplate-mongomongoose

Your browser information:

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

Challenge: Install and Set Up Mongoose

Link to the challenge:

Please remove your DB URI from sample.env - this file does nothing but expose your password and username to the public which is a major security risk.

The name of the project does not make a difference in the case of these lessons, because the default works just fine. If you change it, it should not affect the tests, but it will create a new DB project on your Atlas Dashboard.


Please note:

  • We cannot see your SECRETS - this is a good thing, because the SECRETS could contain sensitive information
  • We can see your sample.env file - do not store sensitive information in this
  • A sample.env file does nothing. Consider it useless, because Replit does not know how to use it (you have not told it how to, and you do not need to tell it how to).
  • All you need to do is ensure you have a MONGO_URI key in your SECRETS, with a value equal to your database URI. Then, you can access it using process.env.MONGO_URI, as you have.

If you are still struggling, please be sure to share the errors you get in the console.

Hope this helps

yes, I rad about the samlpe.env is not actually doing anything but I gave a tyry since I cannot figure out what is the problem and I am still having errors, :frowning:
how do I know which version to install in the json.package?
I used the versions I gro from the “get hint” but few minutes ago i read this in the mongodb page " [Cluster0] Version 4.4.6", so I changed it in the json file and got less errors, but still some. Here they are

and this is the string i insert in the value field of the secret tab
“mongodb+srv://radaminocat:pw@cluster0.mgcis.mongodb.net/myFirstDatabase?retryWrites=true&w=majority”

(password edited))

btw is there a way to double check the password i set on mongodb?

For the package.json file, install the latest version of Mongoose, unless told otherwise in the lesson. You can install the latest version by just installing it - automatically installs the latest.

I am not too sure. I assume you can, but I have not been able to find a quick way.

I created a new cluster and made sure of the pw and updated the new URI. However I do not know which version to use for BOTH mongodb mongoose

In a lesson, if you are not told to install a specific version, install the latest version -default behaviour when installing npm packages.


Replit does make this easy, and, at the same time, trickier than need be. You can either install packages through the terminal (shell) in Replit, by using the npm install package-name (e.g. npm install mongodb), OR you can install packages through the package tool located on the left nav bar in the editor.

done, i checked the latest versin throught the tool bar ( as there I am not sure about using the terminal shell).
I then rerun the app and that is what I get

Could you comment out the require('dotenv').config() line at the top of myApp.js? Then try again.

i have already tried
i commented and got the same bunch of errors :’(

I have also created a brand new cluster, updated the env var but nothing
BTW how do I know the node version used by repl.it?
I am really stuck with these, but honestly I have followed all the steps and doublechecked the env var with no spaces and the “”

You should be able to see something like this in the console:
image


I am sorry for the frustration with all the errors, but it sounds like it is an issue with your database URI string (that is what the error suggests). As a last resort, would you mind DMing me a link to JOIN your repl - it is a link which will give me write access to your app. You do not need to do this - only if you want to.

sure, I have no problem with that at all,

just tell me which link is and where to find it

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