Install & Setup Mongoose

I followed the solution to the t in replit, but did not pass the specs at all. If anyone can help. Thank you.

test results:

"mongodb" dependency should be in package.json
"mongoose" dependency should be in package.json
"mongoose" should be connected to a database

my reference for setting database in mongodb:
https://forum.freecodecamp.org/t/mongodb-cluster-connection-instructions-very-confusing/417145/6?u=shugyoza

solution:
https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-install-and-set-up-mongoose/301540?u=shugyoza

my input in replit, and yes, always stop and run after each change.

.env in replit (secret)

key field: MONGO_URI
value field: "mongodb+srv://userNamePrefilled:passwordIChangedWithPasswordInMongo@cluster0.5lubw.mongodb.net/actualDBNameCreatedInMongoDB?retryWrites=true&w=majority"

package.json

{
	"name": "fcc-learn-node-with-express",
	"version": "0.1.0",
	"dependencies": {
		"express": "^4.14.0",
		"body-parser": "^1.15.2",
		"cookie-parser": "^1.4.3",
		"mongodb": "^3.6.0",
		"mongoose": "^5.4.0",
		"fcc-express-bground": "https://github.com/freeCodeCamp/fcc-express-bground-pkg.git"
	},
	"main": "server.js",
	"scripts": {
		"start": "node server.js"
	}
}

myApp.js

const mongoose = require('mongoose');
const mongo = process.env['MONGO_URI'];
mongoose.connect(mongo);

Your project link(s)

solution: https://replit.com/@shugyoza/boilerplate-express

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36

Challenge: Install and Set Up Mongoose

Link to the challenge:

I saw my mistake, I should use the specific given replit. Managed to pass the first two specs, but still can’t pass the third spect/connect to database.

https://boilerplate-mongomongoose.shugyoza.repl.co

I forked your repo and was able to pass using my mongo uri.
So maybe it is an issue with your mongo uri.

I know people in the past have had issues passing this test if there username or password had special characters in it.
So that might be the issue.

Thanks. It’s not the case. I always created simple password username for toying around. Please let me know if you saw something I missed here. Thank you.

You want to remove the quotes from the value.

But even when I fix that, I am still getting authentication errors for your uri.
I googled the error message and there was stackoverflow answer addressing it.

You can try the solutions provided in that thread.

You can also try my throwaway test uri and see if that works.

mongodb+srv://testproject1:qBHFexBWOImbdxYe@cluster0.dae9o.mongodb.net/myFirstDatabase?retryWrites=true&w=majority

Great! It’s removing the double quotes! Thank you so much!

1 Like

Thank you @jwilkina.oboe, you just save my laptop from throwing away ! :joy:

1 Like