MongoDB and Mongoose - Install and Set Up Mongoose

what’s happening:
// running tests
“mongoose” should be connected to a database
// tests completed

solution: https://3000-freecodecam-boilerplate-r4u7urb3h31.ws-eu108.gitpod.io

Challenge Information:

MongoDB and Mongoose - Install and Set Up Mongoose

i am getting the mistake: // running tests
“mongoose” should be connected to a database
// tests completed and i can’t fix it. i ve tried chainging from ‘’ to “” and habing none on the .env file and even just copying the mongodb link but still didnt work, how can i fix this issue?

myApp.js code:
require(‘dotenv’).config();
const mongoose = require(‘mongoose’);

let Person;

mongoose.connect(process.env.MONGO_URI, {
useNewUrlParser: true,
useUnifiedTopology: true
});

.env: MONGO_URI=“mongodb+srv://mongo:freecodecamp@cluster0.eol8bon.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0”;

Please post the editor link so we can see all the code.

On Gitpod you have to have the .env file (or put the connection string directly into the connect call, which you shouldn’t do).

The code you posted should be passing if you haven’t changed the code otherwise.


Edit: also remember to restart the server when making changes.

1 Like

here is the link: https://freecodecam-boilerplate-r4u7urb3h31.ws-eu108.gitpod.io/
i haven’t changed the code, and today i tested again to see if it passed or not but it didnt, and showed a new error: “mongoose version ^5.11.15” dependency should be in package.json and the previous one, but my package.json has the right version, code: {
“name”: “fcc-mongo-mongoose-challenges”,
“version”: “0.0.1”,
“description”: “A boilerplate project”,
“main”: “server.js”,
“scripts”: {
“start”: “node server.js”
},
“dependencies”: {
“body-parser”: “^1.15.2”,
“dotenv”: “^8.2.0”,
“express”: “^4.12.4”,
“mongoose”: “^5.11.15”
},
“repository”: {
“type”: “git”,
“url”: “GitHub - freeCodeCamp/boilerplate-mongomongoose: A boilerplate for the freeCodeCamp curriculum.
},
“keywords”: [
“node”,
“mongoose”,
“express”
],
“license”: “MIT”
}

We can’t see your code on Gitpod using that link. I think you can share a workspace.

That or you have to push your code to GitHub so we can see all of it and test it.


I don’t think the issue is with your package.json because it comes with the correct version in the starter repo.

here is my workspace snapshot: Dashboard
thank you for your help btw

Don’t use semicolons in the .env file

oh that worked fine, thank you!

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