I have tried solution from other questions but still the same. process.env keep returning undefined but it does return the value in console
console.log(process.env.SSECRET) //return the value
App.use(session({
secret: process.env.SSECRET //return undefined
...
});
I'm using express with typescript, I defined the dotenv at the very top main file like this:
require('dotenv').config({ path: __dirname.replace("/src", "")+"/.env" });
I have tried
import * as dotenv from 'dotenv';
dotenv.config({ path: __dirname.replace("/src", "")+"/.env" })
import { config } from 'dotenv';
config({ path: __dirname.replace("/src", "")+"/.env" })
process.env doesn't include my env variable if I remove the path parameter.