I have a file ENVVARS
that consists of setting many environment variables eg
export ENV_VAR1 = 'mongodb://url'
export ENV_VAR2 = 'dbname'
I need to set these environment variables before I run my script. I'm trying to do something like so:
"test": . ENVVARS && npm run test-s
I have read about the use of cross-env
for setting environment variables inline, but haven't stumbled upon a solution for what I am trying to do, which is setting multiple environment variables through an external file.
Is this possible to do?
Like @VtoCorleno suggested you can use doenv package, which let you set as many ENV VARIABLES
in .env
file, you can access them in your program like: process.env.XYZ
,
Which in your case can be: process.env.ENV_VAR1
process.env.ENV_VAR2
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.