In Node.js, you can retrieve environment variables by key from process.env object.

node -p process.env
node -p process.env.HOME

References

  • http://stackoverflow.com/questions/15058954/node-js-is-there-any-documentation-about-the-process-env-variable
  • https://nodejs.org/api/process.html#process_process_env
  • https://davidwalsh.name/node-environment-variables