close

[Solved] dotenv file is not loading environment variables

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error dotenv file is not loading environment variables in javascript. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How dotenv file is not loading environment variables Error Occurs?

Today I get the following error dotenv file is not loading environment variables in javascript.

How To Solve dotenv file is not loading environment variables Error ?

  1. How To Solve dotenv file is not loading environment variables Error ?

    To Solve dotenv file is not loading environment variables Error How about use require('dotenv').config({path:__dirname+'/./../../.env'}) ?
    Your problem seems to be the execution path.

  2. dotenv file is not loading environment variables

    To Solve dotenv file is not loading environment variables Error How about use require('dotenv').config({path:__dirname+'/./../../.env'}) ?
    Your problem seems to be the execution path.

Solution 1

How about use require('dotenv').config({path:__dirname+'/./../../.env'}) ?

Your problem seems to be the execution path.

Solution 2


If you are invoking dotenv from a nested file, and your .env file is at the project root, the way you want to connect the dots is via the following:

require('dotenv').config({path:'relative/path/to/your/.env'})

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also Read

Leave a Comment