Quoting from dotenv's npm page
Should I have multiple .env files?
No. We strongly recommend against having a "main" .env file and an
"environment" .env file like .env.test. Your config should vary
between deploys, and you should not be sharing values between
environments.'
But to use .env.local or .env.test or any other environment.. one at a time is
require('dotenv').config({ path: `.env.${process.env.NODE_ENV}` })
If you still want to do it refer to dotenv-flow at
https://www.npmjs.com/package/dotenv-flow
dotenv-flow comes with the feature of overwriting variables at environments.