@chatopera/dotenv

Expand environment variables using dotenv

Usage no npm install needed!

<script type="module">
  import chatoperaDotenv from 'https://cdn.skypack.dev/@chatopera/dotenv';
</script>

README

dotenv-expand

dotenv-expand

Dotenv-expand adds variable expansion on top of dotenv. If you find yourself needing to expand environment variables already existing on your machine, then dotenv-expand is your tool.

BuildStatus NPM version js-standard-style

Install

npm install @chatopera/dotenv --save

Usage

Define vars in .env

OTHER_ENV=foo
YOUR_ENV_VAR=$OTHER_ENV/bar

As early as possible in your application, require dotenv and dotenv-expand, and wrap dotenv expand around dotenv.

require('@chatopera/dotenv').config(process.cwd() + '/.env')
process.env["YOUR_ENV_VAR"]

See test/.env for examples of variable expansion in your .env file.