mongoose.connect in my express app have name: MongoParserError , message: 'URI malformed, cannot be parsed'

I have some problem. please check, that your uri isn't undefined you can use console.log(db)


Hey I resolved this issue:

Try this, first insure you have .env file with the correct link, then go over to index.js and locate require(“dotenv”).config()

change the name from dotenv to env and the back to dotenv again.

what this does is it forces the MongoDb to restart, I tried using Command + S and it gave me the same err but after changing the values in index.js it works fine. please refer to the image


First check if the variable/env variable can be logged in the console

console.log(db);

If you are executing your application from some other file than your entry point, then add this in that other file

require('dotenv/config');

OR

require('dotenv').config();

OR

any such import(according to the package you are using) in connection file too.