Why dotenv not able to load environment variables?

139 Views Asked by At

I have the following directory structure: enter image description here

I am using dotenv to load environment variables but its not loading them.It gives undefined even though I have defined them in the .env file.

The code in index.js is here:

enter image description here

I've even tried the following for requiring:

require('dotenv').config();

require('dotenv').config({path:'C:\Users\xuios\Desktop\AirlineManagementProject\FlightsAndSearch\src\.env'}); // absolute path

require('dotenv').config({path:'FlightsAndSearch\src\.env'}); //relative path

However it still doesnt load the env variables defined as :enter image description here

0

There are 0 best solutions below