Load environment variables from .env files
npm install @dot/envLoad environment variables from .env files.
This tiny package composes a few packages in order to load .env intelligently:
- dotenv
- dotenv-expand
- find-up
Differences with dotenv:
- Automatically expands variables such as ${NODE_ENV} within the .env files
- Searches the immediate directory (current working directory) for an .env file, and if not found, continues to look in parent directories until a .env file is found, or .git is encountered.
Possible future features:
- [ ] Composing multiple .env files
- [ ] Extending .env files
This package requires an Active LTS Node version (v18+).
Using pnpm:
``console`
pnpm add @dot/env
Usage is straightforward:
`ts``
import '@dot/env';
That's it. You're good to go.