Toggle between multiple .env files like .env.development with node.js

You can specify which .env file path to use via the path option with something like this:

require('dotenv').config({ path: `.env.${process.env.NODE_ENV}` })

Leave a Comment