Setup MongoDB connection

Tell us what’s happening:
Describe your issue in detail here.
I am currently working with freecodecamp exercises with node.js.
I am trying setup connection to my MongoDB database using mongoos.

Your code so far
Code in myApp.js:
const mongoose = require(‘mongoose’)
mongoose.connect(process.env.MONGO_URI, {useNewUrlParser: true, useUnifiedTopology: true });

Code in sample.env:
MONGO_URI = ‘‘mongodb+srv://’’

Code in package.json:
“name”: “fcc-mongo-mongoose-challenges”,
“version”: “0.0.1”,
“description”: “A boilerplate project”,
“main”: “server.js”,
“scripts”: {
“start”: “node server.js”
“dependencies”: {
“body-parser”: “^1.15.2”,
“dotenv”: “^8.2.0”,
“express”: “^4.12.4”,
“mongodb”: “~3.6.0”,
“mongoose”: “~5.4.0”
“repository”: {
“type”: “git”,
“url”: “GitHub - freeCodeCamp/boilerplate-mongomongoose: A boilerplate for the freeCodeCamp curriculum.
“keywords”: [
“license”: “MIT”

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.60 Safari/537.36

Challenge: Install and Set Up Mongoose

Link to the challenge:

The environment variables should be inside a .env file, not sample.env and you want to use the dotenv package as well (this does not work on Replit).

On Replit the environment variables should be added to the Secrets.

Also, I assume you intentionally removed the password from the mongodb connection string before posting it?

Yes, I did remove the authentication details. I will try your suggestion