Like dotenv, but dynamic!
# npm
npm install -s dynamic-dotenv
# yarn
yarn add dynamic-dotenv
This package essentially behaves the same as using the manual initialisation of the dotenv package. The main difference to dotenv, is that the response value is an EventEmitter. It will emit "change" events every time the loaded env file changes, as well as update the process.env values when that happens. If an error occurs, either from filesystem interaction or from dotenv, it will also be emitted as an "error" event.
import dynamicDotenv from 'dynamic-dotenv'
const dd = dynamicDotenv(/* you can pass the same options as dotenv here */)
// process.env now contains the values in your .env file
dd.on('change', () => {
// this event will be emitted every time the .env file changes
})