Check out example codes for "require('dotenv').config() typescript". It will help you in understanding the concepts better.

Code Example 1

import dotenv from 'dotenv';

dotenv.config();

export const YOUR_ATTRIBUTE = process.env.YOUR_ATTRIBUTE!;

Learn ReactJs, React Native from akashmittal.com