mongoose.connect(), first argument should be String, received undefined
To read from .env file you have to install dotenv ( npm i dotenv / yarn add dotenv) and then just add this on top of your file.
const dotenv = require("dotenv");
dotenv.config();
I think you miss importing env
file.
require('dotenv').config({ path: 'ENV_FILENAME' });