Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/hex/src/lib/options/deps.ts>dotenv.ConfigOptions

An ecosystem delivering practices, philosophy and portability. Powered By Deno and JavaScript.
Latest
interface dotenv.ConfigOptions
import { type dotenv } from "https://deno.land/x/hex@0.6.5/src/lib/options/deps.ts";
const { ConfigOptions } = dotenv;

Properties

optional
path: string = "./.env"

Optional path to .env file.

optional
export: boolean = false

Set to true to export all .env variables to the current processes environment. Variables are then accessable via Deno.env.get(<key>).

optional
safe: boolean

Set to true to ensure that all necessary environment variables are defined after reading from .env. It will read example to get the list of needed variables.

If any of the defined variables is not in .env, an error will occur. This method is preferred because it prevents runtime errors in a production application due to improper configuration. Another way to supply required variables is externally, like so:

GREETING="hello world" deno run --allow-env app.ts
optional
example: string = "./.env.example"

Optional path to .env.example file.

optional
allowEmptyValues: boolean = false

Set to true to allow required env variables to be empty. Otherwise, it will throw an error if any variable is empty.

optional
defaults: string = "./.env.defaults"

Path to .env.defaults file which is used to define default values.

# .env.defaults
# Will not be set if GREETING is set in base .env file
GREETING="a secret to everybody"
optional
restrictEnvAccessTo: StringList

List of Env variables to read from process. By default, the complete Env is looked up. This allows to permit access to only specific Env variables with --allow-env=ENV_VAR_NAME.