DEV Community

Discussion on: Environment variables in Node.js. The Right way!

 
numtostr profile image
Vikas Raj

For example, heroku has a option in app settings to enter environment variable.

Thread Thread
 
thesuhu profile image
The Suhu

yes, in heroku there is an option to store that. but how if we use own server?

Thread Thread
 
numtostr profile image
Vikas Raj • Edited

Like this

// keys.js ======
module.exports = {
    PORT: process.env.PORT,
    WHO_AM_I: process.env.WHO_AM_I,
};
Thread Thread
 
thesuhu profile image
The Suhu

ok, thank you.

Thread Thread
 
yogendra3236 profile image
Yogendra

But, still we're using 'process.env', which uses to 'dotenv' package in production?

Thread Thread
 
thesuhu profile image
The Suhu

In production I didn't use .env, I store all credentials on host environment or if I use docker, I store it in docker secrets.

Thread Thread
 
yogendra3236 profile image
Yogendra

Cool, thanks!