Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need help to use dotenv after npm run build #81

Open
ashokdey opened this issue Oct 9, 2018 · 1 comment
Open

Need help to use dotenv after npm run build #81

ashokdey opened this issue Oct 9, 2018 · 1 comment

Comments

@ashokdey
Copy link

ashokdey commented Oct 9, 2018

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
@ndabAP
Copy link
Contributor

ndabAP commented May 15, 2019

You can just do:

import { load } from 'dotenv'

// Load .env file
load()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants