Skip to content

dotenvFileSource

dotenvFileSource(path): ConfigSource

Defined in: sources.ts:41

A source that reads a .env-format file from disk.

Node only. Uses dynamic import of node:fs/promises so it doesn’t break browser bundles, but actually calling load() in a browser will throw — filter sources by environment in your loader.

Missing files (ENOENT) are treated as empty config so .env.local and similar optional files can be listed unconditionally. Other I/O failures (permission denied, “is a directory”, etc.) are re-thrown so they surface to loadConfig’s onSourceError / logger — masking them would just make misconfiguration debug sessions miserable.

string

ConfigSource

sources: [dotenvFileSource(".env.local"), dotenvFileSource(".env")]