MongoDB and Mongoose - Install and Set Up Mongoose need help!

MongoDB and Mongoose - Install and Set Up Mongoose need help!
0

#1
"dependencies": {
		"express": "^4.12.4",
		"body-parser": "^1.15.2",
    "mongodb" : "^3.6.8",
    "mongoose" : "^5.3.9"
	},

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

MONGO_URI=mongodb://simba:[email protected]:31963/databazz

The error says mongoose isn’t connected…plzz help!!


#2

Hi, I think you don’t need to add mongo dependency. But you need to import .env, and add the uri in .env file.
Check on your mlab account the exact url of the db, it includes mongodb:// at begining.

Best regards


#3

You called MONGO_URI before you set the actual variable.

Put the line below before the one about mongoose.connect()

const MONGO_URI="mongodb://simba:[email protected]:31963/databazz"

Follow this Getting Started instructions from the mongoose docs for more details.


#4

I’ve included mongodb:// in the beginning,…it’s still not working…


#5

It’s not working…!!!


#6

You’re reading the MONGO_URI from process.env, did you setup that correctly? If not you can always use directly like:

const mongoose = require('mongoose');
mongoose.connect('simba:[email protected]:31963/databazz');

#7

Can anyone help…I’ve now deleted the previous user and changed the password in a way that it not includes special characters…still it’s showing error.