Skip to content

Need help to use dotenv after npm run build #81

@ashokdey

Description

@ashokdey

I am not able to understand that why dotenv is not working after building

In src/index.js, I am having the following code,

import path from 'path';
const envPath = path.resolve(__dirname, '../.env');

require('dotenv').config({ path: envPath});
import app from './app';

Now after running npm start, the .env file which is located in the root folder is not working, all the env variables are undefined. Am I missing something?

**Alternative ways **
These are the alternative ways I am using right now:

  • docker-compose
  • PM2 ecosystem.config.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions