Skip to main content

@std/dotenv@0.215.0

latest
Works with
It is unknown whether this package works with Browsers, Deno, Node.js, Cloudflare Workers, Bun
It is unknown whether this package works with Browsers
It is unknown whether this package works with Deno
It is unknown whether this package works with Node.js
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Bun
JSR Score70%
Published2 years ago (0.215.0)
default

Parses and loads environment variables from a .env file into the current process, or stringify data into a .env file format.

Classes

c
MissingEnvVarsError(
message: string,
missing: string[]
)

Error thrown in load and loadSync when required environment variables are missing.

  • missing: string[]

    The keys of the missing environment variables.

Functions

f
load(unnamed 0?: LoadOptions): Promise<Record<string, string>>

Load environment variables from a .env file. Loaded variables are accessible in a configuration object returned by the load() function, as well as optionally exporting them to the process environment using the export option.

f
loadSync(unnamed 0?: LoadOptions): Record<string, string>

Works identically to load, but synchronously.

f
parse(rawDotenv: string): Record<string, string>

Parse .env file output in an object.

f
stringify(object: Record<string, string>): string

Stringify an object into a valid .env file format.

Interfaces

I

Options for load and loadSync.

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

  • defaultsPath: string | null

    Optional path to .env.defaults file which is used to define default (fallback) values. To prevent the default value from being used, set to null.

  • envPath: string | null

    Optional path to .env file. To prevent the default value from being used, set to null.

  • examplePath: string | null

    Optional path to .env.example file which is used for validation. To prevent the default value from being used, set to null.

  • export: boolean

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

parse

Functions

f
parse(rawDotenv: string): Record<string, string>

Parse .env file output in an object.

stringify

Functions

f
stringify(object: Record<string, string>): string

Stringify an object into a valid .env file format.

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@std/dotenv

Import symbol

import * as dotenv from "@std/dotenv";
or

Import directly with a jsr specifier

import * as dotenv from "jsr:@std/dotenv";