Dotenv Build Status

Dotenv handling for deno.


Setup a .env file in the root of your project.

# .env
GREETING=hello world

Then import the configuration using the config function.

// app.ts
import { config } from "";


Then run your app.

> deno app.ts
{ GREETING: "hello world" }


Auto loading

load.ts automatically loads the local .env file on import and exports it to the process environment:

# .env
GREETING=hello world
// app.ts
import "";
import { env } from "deno";

> deno --allow-env app.ts
hello world

Safe Mode

To enable safe mode, create a .env.example file in the root of the project.

# .env.example

Then import the configuration with safe option set to true.

// app.ts
import { config } from "";

console.log(config({ safe: true }));

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 suply required variables is externally, like so:

GREETING="hello world" deno --allow-env app.ts

Parsing Rules

The parsing engine currently supports the following rules:



Issues and pull requests welcome. Please run make fmt before commiting.


View repository on GitHub