node dotenv

  1. Install the dotenv package using npm.
  2. Require the dotenv package at the top of the entry file of your Node.js application (e.g., index.js) using the require() function.
  3. Call the config() method on the result of requiring the dotenv package to load the environment variables from the .env file into the process.env object.