[Disclaimer: This is my first post on this forum, if I am not following some part of the posting guidelines please let me know.]
I am on the Mongoose and MongoDB section of this certification in the curriculum. I required mongoose and tried to connect to my database using the URI I copy pasted from MongoDB atlas:
let mongoose = require("mongoose");
mongoose.connect(
process.env.MONGO_URI
);
console.log(mongoose.connection.readyState) // This is 2 ("connecting")
My URI in the .env
file has the form:
MONGO_URI="mongodb+srv://haadbhutta:<password_redacted>@fcc-cluster.3lteu.mongodb.net/?retryWrites=true&w=majority&appName=fcc-cluster"
I ran npm install mongoose@latest
and npm install mongodb
in the terminal and my package.json
shows:
"dependencies": {
"body-parser": "^1.15.2",
"dotenv": "^8.2.0",
"express": "^4.12.4",
"mongodb": "^6.11.0",
"mongoose": "^8.8.4"
}
The challenge (challenge number 1 about setting up mongoose and mongodb) will not accept my submission. with the following output:
// running tests
1. "mongoose version ^5.11.15" dependency should be in package.json
2. "mongoose" should be connected to a database
// tests completed
// console output
[Error]
[Error]
I deliberately changed the mongoose version because of problems with useUrlParser
and useUnifiedTopology
.
What am I doing wrong?