+ 1

Regarding NodeJS environment variable

I have assigned some data to one environment variable and the name of the environment variable is on local variable. Example: My Environment Variable: USERX = bibek Local variable containing name of environment variable: hasNameOfEnvVar = "USERX" Now I need to access the value stored in environment variable (USERX) that is (bibek) using the local variable (hasNameOfEnvVar) How can I do that? process.env.hasNameOfEnvVar didn't work, My program works exactly like this I don't have any other alternatives to do the job. So, I need suggestions as soon as possible.

18th Nov 2021, 4:42 PM
Bibek Oli
Bibek Oli - avatar
3 Antworten
0
You should use one library like "dotenv" to manage the environment variable
18th Nov 2021, 6:05 PM
Jairo Soto
Jairo Soto - avatar
0
Jairo Soto yes I am using dotenv and global variable are on .env files. Please tell if you have the solution to the question.
19th Nov 2021, 1:31 AM
Bibek Oli
Bibek Oli - avatar
0
Import dotenv like this, require('dotenv').config()
19th Nov 2021, 2:32 AM
Jairo Soto
Jairo Soto - avatar