Setting up Environment Variables Linux/Mac Os
Environment variables are added to the ‘.bash_profile’ directory,
for the current user.
We will be using vim editor for viewing and editing environment
variables (You can use any other editor if you like).
1. Open a new terminal
2. Type vi ~/.bash_profile
3. Now you can add desired environment variable by using the export
keyword. For e.g.
export USER_EMAIL="user@codingninjas.in"
export USER_PASSWORD="coding"
4. Now to save the bash_profile press Esc followed by ‘:wq’ (write
and quit)
5. Now These can now be used in the project using
userEmail = process.env.USER_EMAIL
userPassword = process.env.USER_PASSWORD
Setting up Environment Variables Windows
1. To add environment variables in windows, go to start, search
environment variables
2. Now under system variables click on new
3. Now set the variable name what you require and also set the
values.For example set variable name as port and value as 8000
4. For using the environment variable in the project use
process.env.Variable_name (e.g. process.env.port )