Not finding .env

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:
42%20PM

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:

Do you have a link to your Glitch project we can take a look at?

Thanks for your response and help, Randell :slight_smile:

Here’s the project link: https://glitch.com/~continuous-rutabaga

What is the exact error message you are seeing in the log?

the URI should be a string;

MONGO_URI='mongodb+srv://admin:@cluster0-canur.mongodb.net/test?retryWrites=true&w=majority

Then make it a string. Add single quotes around the URI.

Thank you both. I made the URI into string, and then dug a bit deeper into the error message and it turned out that resetting the password for the user in MongoDB did the trick. Thank you!