A zero-dependency module that loads environment variables from a .env file into process.env for Node.js applications.
Dotenv is a Node.js module that loads environment variables from a `.env` file into the `process.env` object. It solves the problem of managing configuration separately from code, allowing developers to keep sensitive data like API keys and database URLs out of source control while ensuring portability across different deployment environments.
Node.js developers building applications that require environment-specific configuration, particularly those following The Twelve-Factor App methodology or working in teams where sharing configuration securely is essential.
Developers choose Dotenv for its simplicity, zero-dependency design, and robust parsing capabilities. It's the industry-standard solution for managing environment variables in Node.js, with extensive framework compatibility and advanced features like multi-environment support and preloading.
Loads environment variables from .env for nodejs projects.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Has no external dependencies, keeping the module lightweight and minimizing bundle size, as emphasized in its GitHub description.
Supports advanced cases like multiline values, comments, and quoted strings with clear parsing rules documented in the FAQ section.
Offers extensive customization through config(), including custom paths, encoding, debugging, and override controls, as detailed in the Docs.
Works seamlessly with ES6 imports and integrates with popular frameworks like Express and Next.js, with specific examples provided in the README.
Core functionality lacks variable expansion, encryption, and syncing, which require the separate dotenvx tool—a limitation repeatedly highlighted in the README.
The module must be imported before other ES6 modules to load variables correctly, an unintuitive behavior that the FAQ warns can confuse developers.
For frontend frameworks like React, additional Webpack configuration or polyfills are needed, as dotenv doesn't work out-of-the-box in browser environments.