motdotla / dotenv

Loads environment variables from .env for nodejs projects.
https://www.dotenvx.com
BSD 2-Clause "Simplified" License
19.01k stars 853 forks source link

In ES6 DOTENV enviroment not getting #785

Closed paraschouhan15 closed 7 months ago

paraschouhan15 commented 9 months ago

I have tried to get dotnev enviroment but getting undefined** //this is code i am using

`import express from 'express'; import dotenv from 'dotenv'

dotenv.config()

console.log(process.env.PORT)

const app = express();

//middlewares

app.get('/', (req, res) => { res.send( "

Welcome to my aapp

" ); }) //port

app.listen(8000, () => { console.log(Server running on port number 8000) }) `

paraschouhan15 commented 9 months ago

I have DOTENV file in which declared PORT = 8000

AnirudhKaranth commented 8 months ago

@paraschouhan15 This is the syntax for ES6 image