To toggle between multiple .env files like .env.development with Node.js, we use the dotenv
library.
For instance, we write
require("dotenv").config({ path: `.env.${process.env.NODE_ENV}` });
to call config
with an object with the path
property to point to the .env file path we want to use.
process.env.NODE_ENV
is the NODE_ENV
environment variable value.