Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

94
Views
process.env returning undefined but not in console

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.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!