@dotenvx/dotenvx
Drop-in replacement for dotenv with encrypted .env files, multi-environment support, and runtime injection.
Official Documentation ↗v1.0. Check the official docs for the latest API surface.Installation
npm install @dotenvx/dotenvxMethods
No methods match this filter.
@dotenvx/dotenvx is drop-in replacement for dotenv with encrypted .env files, multi-environment support, and runtime injection. This page documents the core methods, installation, and common usage patterns for the current stable release.
Installation
Install @dotenvx/dotenvx with your preferred package manager using the command shown in the frontmatter. The package is published to the npm registry and ships with TypeScript types where applicable.
Core methods
The methods listed in the frontmatter cover the primary API surface. Each signature reflects the v1.0 release. Consult the official documentation linked in sourceUrl for advanced options, edge cases, and breaking changes between major versions.
Frequently asked questions
The faq section in the frontmatter answers the most common questions about @dotenvx/dotenvx, including comparisons with alternatives, configuration tips, and runtime requirements. If your question is not covered, check the source URL for the full guide.
Errors
The official API reference declares the following error types:
ALREADY_ENCRYPTED(encrypt –with场景的失败错误码(官方 README)) — official text: “A different public key, or an encrypted:value without a matching declared public key, fails withALREADY_ENCRYPTEDand leaves the file unchanged.” (source: https://cdn.jsdelivr.net/gh/dotenvx/dotenvx@latest/README.md, fetched 2026-11-08T18:44:00+08:00)
Security
Official security statements captured from the package documentation:
- 官方称加密后的 .env 可安全提交到 git 共享 — “Commit your encrypted
.envfiles with your code. It’s safe. Now you can securely share secrets through git.” (source: https://cdn.jsdelivr.net/gh/dotenvx/dotenvx@latest/README.md, fetched 2026-11-08T18:44:00+08:00) - 官方声明 .env 中值为密文,只有私钥可解 — “The values become ciphertext and only your private key can unlock them.” (source: https://cdn.jsdelivr.net/gh/dotenvx/dotenvx@latest/README.md, fetched 2026-11-08T18:44:00+08:00)
API reference evidence
Fetched from official sources on 2026-11-08T18:44:00+08:00 via WebFetch https://cdn.jsdelivr.net/gh/dotenvx/dotenvx@latest/README.md;HTTP GET https://unpkg.com/@dotenvx/dotenvx@latest/src/lib/main.d.ts.
config→ signature from https://unpkg.com/@dotenvx/dotenvx@latest/src/lib/main.d.ts; official text: “export function config(options?: DotenvConfigOptions): DotenvConfigOutput;”dotenvx→ signature from https://cdn.jsdelivr.net/gh/dotenvx/dotenvx@latest/README.md; official text: “Dotenvx uses your private key to decrypt and inject your secrets just-in-time to your code.sh $ dotenvx run -- node index.js ⟐ injected env (2) from .env”
FAQ
- How does encryption work?
- Run dotenvx encrypt to generate an encrypted .env and a private key; decrypt at runtime with the key.
- Is it backward compatible with dotenv?
- Yes. The config function matches the dotenv API; swap the import.
- Can I load multiple files?
- Yes. Pass path: ['.env', '.env.local'] to load and merge in order.
Report a problem with this API docOpens a pre-filled issue on GitHub.