filmov
tv
How to access environment variables in NodeJS by adding .env file
![preview_player](https://i.ytimg.com/vi/IrbspITE54c/maxresdefault.jpg)
Показать описание
In this video we're gonna learn how to add .env file and access environment variables in NodeJS project.
In real world projects we cannot put all our sensitive information like Database credentials, API tokens ..etc. in our code plain hardcoded. So, we use Environment variables for that. We define all our Environment related variables in a separate file: we call it .env file and we have different .env files for different environments.
So, in this video we have simple NodeJS project written with TypeScript and we're gonna add a .env file and put some values there (Port, Environment ..etc.) and access them in the code.
00:00 Intro
00:24 Why we use .env files
01:37 Add .env files to our existing project
02:54 Install dotenv package
08:33 Outro
Create a REST API with NodeJS:
Hit Subscribe and smash the Like button.
Become a Patreon and support me!
In real world projects we cannot put all our sensitive information like Database credentials, API tokens ..etc. in our code plain hardcoded. So, we use Environment variables for that. We define all our Environment related variables in a separate file: we call it .env file and we have different .env files for different environments.
So, in this video we have simple NodeJS project written with TypeScript and we're gonna add a .env file and put some values there (Port, Environment ..etc.) and access them in the code.
00:00 Intro
00:24 Why we use .env files
01:37 Add .env files to our existing project
02:54 Install dotenv package
08:33 Outro
Create a REST API with NodeJS:
Hit Subscribe and smash the Like button.
Become a Patreon and support me!