I am currently building a backend in nodejs. I am thinking about how to add an environment configuration to the project. My idea is that I have a /config
folder in which I have my envparser.ts
(have to think about a better name for this ^^) which interprets my .env
files to use them as regular javascript const. By using scripts in my package.json
I would like to have the ability to switch the envs. But I don“t know how to switch between multiple .env
files using dotenv.
File structure:
config/
.env.development
.env.production
envparser.ts
Scripts:
yarn start yarn start -p/-production //Or a different Syntax to change envs