Multiple .env files in node

  "scripts": {
    "start-local": "NODE_ENV=local node index.js",
    "start-prod": "NODE_ENV=prod node index.js",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  • .env.local
  • .env.prod
import dotenv from "dotenv";
dotenv.config({ path: `./.env.${process.env.NODE_ENV}` });

Leave a Reply

Your email address will not be published.

ANOTE.DEV