Read environment variables in Node.js

Jayesh picture Jayesh · Feb 2, 2011 · Viewed 634.2k times · Source

Is there a way to read environment variables in Node.js code?

Like for example Python's os.environ['HOME'].

Answer

Jayesh picture Jayesh · Feb 2, 2011
process.env.ENV_VARIABLE

Where ENV_VARIABLE is the name of the variable you wish to access.

See Node.js docs for process.env.