Tell us what’s happening:
When I “start the project using Glitch” and follow the link in this lesson: https://www.freecodecamp.org/learn/apis-and-microservices/mongodb-and-mongoose/
I don’t see a .env file in the template. Instead, I see the following:
No worries, I just created a new blank file called .env. Based on what others have posted, my code seems like it should work but it isn’t. My suspicion is that it has something to do with the template and the fact that the path isn’t process.env because I created it?
Your code so far
.env file
MONGO_URI=mongodb+srv://admin:<myactualpassword>@cluster0-canur.mongodb.net/test?retryWrites=true&w=majority
myApp.js file
const mongoose = require('mongoose');
mongoose.connect(process.env.MONGO_URI);
dependencies:
"dependencies": {
"express": "^4.12.4",
"body-parser": "^1.15.2",
"mongoose": "^5.7.7",
"mongodb": "^3.3.2"
},
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36
.
Challenge: MongoDB and Mongoose - Install and Set Up Mongoose
Link to the challenge: