express-babel
express-babel copied to clipboard
Need help to use dotenv after npm run build
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
You can just do:
import { load } from 'dotenv'
// Load .env file
load()