This is a simple guide on how to use .env
in a typescript project.
I am starting to learn typescript, so hopefully this will be useful to all newbie programmers using typescript out there
- Install
dotenv
library.
npm install dotenv
- Include inside the file that will make use of the environment variables.
import * as dotenv from "dotenv";
dotenv.config();
- Call the variables in files, like so.
export const configDev = {
developerName: process.env.developerName,
};
Top comments (0)