if you are seeing the same issue. Here is the quick fix:
const mongoose = require('mongoose');
const dotenv = require('dotenv');
dotenv.config({ path: './config.env' });
const app = require('./app');
const DB = process.env.DATABASE; // this is your database URL your env name can be different. In this case it is DATABASE
console.log('Database URI:', DB); // log it to check the DB string.
If you are using VS code debugger please configure your launch.json file to include your env for a while. In configurations list add {"env": { "DATABASE": "paste your url here" }}
try to ignore the outside bracket as it is already there with other options inside. Run the debugger with breakpoints at consol.log. This should help you understand if your URL is correct or what is the issue.