MongoDB and Mongoose - Install and Set Up Mongoose

@opereverzeva still not going, cant seem to find the fault here.

Can you put up the connection string you are trying to use (x out or put password in place of your real password).

not working, don’t think it has anything to do with my dependencies.

@patrickndifon Am suspecting its my .env file, some end it at “MONGO_URI='mongodb+srv://” others at “MONGO_URI='mongodb+srv://” , not sure which is correct.

@RobotFights I’m pretty sure your problem has nothing to do with “your code”.
You just overlooked the package.json from the boilerplate glitch loads for you automatically and left

You can just delete it or if you still want to restrict need to update the package.json to either the node version you are running on glitch or restrict the engines object in a different manner so only runs in the node versions that your code supports. :wink:

Also, you may have to look for dotenv in npm and take a read…

@gpedro I have updated all my dependencies, and changed node version: Still not working…

@RobotFights I had to end with the ? To make it work. Also don’t use any quotes in the .env file.

@eoja I also ended with '’ , still doesn’t work, and no quotes around either.

Still trying to fix this for months, here is my live app link if there’s any help

I had a problem with the .env variable, and to fix it I had to add “dotenv”: “^8.1.0” as a dependency a initialize it on the server.js file, like this:

const dotenv = require('dotenv').config()

Now I can’t get the FCC challenge to evaluate my glitch url. I keep getting this and no more:

// running tests
// tests completed

I’m getting "Missing CORS headers ‘Access-Control-Allow-Origin’ on my browser console… Any ideas why this is happening???

I restarted the hole thing but using the github repo and not the glitch link in the instrucctions, turns out that the glitch link clones a repo that is not updated and there are a lot of things missing. Even so I had to add the “dotenv” dependency like I said before on the post, in order to get everything working!!

thank you, you saved my day !!!

Your live app link is not helpful, it just displays “OK!”

We’re you using dotenv in your local environment? You need it in your local environment but not on glitch. There is a lot of confusion about the glitch link to submit for an answer. You have to click “show” then “app in new window” and use that URL.

I have been using the link to pass other projects, but now it wouldn’t work.

One place where I made a mistake (which no one here corrects) was not adding the ‘MONGO_URI’ connect link as a string. It must be added as string in the ‘.env’ file.


I used try…catch statement for identifying this error and log it to the console.

try {
  const mongoose = require('mongoose');
} catch(e) {

Hope that helps!

done all that before, still not working: getting this error:======= (node:2135) [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.

been stuck for months now, if someone can tell what am doing wrong

If you are trying to do the “Install and Set Up Mongoose” challenge it looks like you are using the wrong glitch link for the project. Your screen shots look like the link from a previous challenge in which mongoose was not used. I would start again with the link here. Also, don’t use quotes in the .env file.

Oh my God, this was my problem too. Thanks for posting!!!