title: Cannot read property 'connect' of undefined in env file
body: <pre><code>const dotenv = require('dotenv');
  const { mongoose } = require('mongoose');
  
  // const bodyParser = require('body-parser');
  const app = express();
  app.use(express.json());
  const DB = `mongodb+srv://${process.env.MONGO_DB_USER}:${process.env.MONGO_DB_PASSWORD}@cluster0.70g8h.mongodb.net/${process.env.MONGO_DB_DATABASE}?retryWrites=true&amp;w=majority`
  mongoose.connect( DB ,
   {
      useNewUrlParser: true,
      useUnifiedTopology: true,
      useFindAndModify: false,
      useCreateIndex: true
    })
  .then( ()=&gt;console.log('Connection Success ..'))
  .catch( (err)=&gt;console.log(' Not Connection Success'));
  
  dotenv.config({path:'./config.env'});
  app.get('/', (req, res,next) =&gt; {
      
      res.status(200).json({
          message:'Hello'
      });
  
  });
  app.post('/data', (req, res,next) =&gt; {
      
      res.status(200).json({
          message: req.body
      });
      
  
  });
  
  
  
  app.listen(process.env.PORT,()=&gt;{
      console.log(`Server is runing at the port : ${process.env.PORT}`);
  })
  
  </code></pre>
  <p>Getting this error when using this code, I would like to know what is causing the error and any possible fixes. I am using atlas MongoDB</p>
  <pre><code>this is the output 
  
  D:\WebDevelopment.Ravi\Projects\mern_ecommerce\e-commerce-backend\src\index.server.js:9
  mongoose.connect( DB ,
           ^
  
  TypeError: Cannot read property 'connect' of undefined
      at Object.&lt;anonymous&gt; (D:\WebDevelopment.Ravi\Projects\mern_ecommerce\e-commerce-backend\src\index.server.js:9:10)
      at Module._compile (internal/modules/cjs/loader.js:1063:30)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
      at Module.load (internal/modules/cjs/loader.js:928:32)
      at Function.Module._load (internal/modules/cjs/loader.js:769:14)
      at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
      at internal/main/run_main_module.js:17:47
  [nodemon] app crashed - waiting for file changes before starting..
  </code></pre>
  <p>Getting this error when using this code, I would like to know what is causing the error and any possible fixes. I am using atlas MongoDB</p>