Tell us what’s happening:
I am having difficulties when running tests on the Mongo DB setup Challenge. I have counter checked my code several time and even tried variations suggested here in the forums and even several versions of mongoose but still I get the prompt that “Mongoose should be connected to a database”
Any assistance will be much appreciated.
Below is my code:
Your code so far
myApp.js
const mongoose = require('mongoose');
var Schema = mongoose.Schema;
mongoose.connect(process.env.MONGO_URI, { useNewUrlParser: true, useUnifiedTopology: true });
.env file(not my real password or username)
MONGO_URI='mongodb+srv://username:password123@cluster0-2ewwt.mongodb.net/test?retryWrites=true&w=majority'
package.json
{
"name": "fcc-mongo-mongoose-challenges",
"version": "0.0.1",
"description": "A boilerplate project",
"main": "server.js",
"scripts": {
"start": "node server.js"
},
"dependencies": {
"express": "^4.12.4",
"body-parser": "^1.15.2",
"mongoose": "^5.9.1",
"mongodb": "^3.5.2"
},
"engines": {
"node": "4.4.5"
},
"repository": {
"type": "git",
"url": "https://hyperdev.com/#!/project/welcome-project"
},
"keywords": [
"node",
"hyperdev",
"express"
],
"license": "MIT"
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36
.
Challenge:
MongoDB and Mongoose - Install and Set Up Mongoose
Link to the challenge:
https://www.freecodecamp.org/learn/apis-and-microservices/mongodb-and-mongoose/install-and-set-up-mongoose