Is there a way to read environment variables in Node.js code?
Like for example Python's os.environ['HOME']
.
process.env.ENV_VARIABLE
Where ENV_VARIABLE
is the name of the variable you wish to access.
When using Node.js, you can retrieve environment variables by key from the process.env
object:
for example
var mode = process.env.NODE_ENV;
var apiKey = process.env.apiKey; // '42348901293989849243'
Here is the answer that will explain setting environment variables in node.js