Quick Start
dotenv-run
can be installed as a standalone CLI or as a plugin for your favorite bundler.
You can also use @dotenv-run/core
to build your own integration.
They all share the same API and can be used as a drop-in replacement.
@dotenv-run/cli
is a standalone CLI that can be used to run a script with environment variables defined in a .env
file.
install
.env file
Create a .env
file with the following content:
npx dotenv-run
Run dotenv-run
using npx:
command line
Override the value of API_INSTANCE
from the command line:
multiple .env files
Override the value of API_INSTANCE
and API_HOST
inside the .env.prod
file:
Use NODE_ENV
to instruct dotenv-run
to load .env.prod
in addition to .env
:
process.env
Environment variables are available in process.env
:
monorepo setup ✨
In a monorepo configuration, .env.*
files can be defined in the root workspace and overriden by each application.
bundler
dotenv-run
can be used as a plugin for your favorite bundler. It support all the features of the CLI like .env.*
files, cascading configuration, monorepo setup, etc.
PS: you don’t need to install @dotenv-run/cli
if you are using @dotenv-run/webpack
.
The list of options of @dotenv-run/webpack
is the same as @dotenv-run/cli
as well as all the other plugins as they all share the same API.