.env file
To set up the .env, follow these commands!
- Setup file!
# your terminal should be in your project folder (check pwd!)
# create .env file
touch .env
# download env npm package
npm i dotenv
- add dotenv to be used in our application
add this into server.js
server.js
// require dotenv config
require('dotenv').config();
- add your DATABASE_URL into your .env file your previously created
.env
DATABASE_URL=<database-url-here-without-any-quotes>
// DATABASE_URL=mongodb+srv://<your-username>:<your-password>@cluster0-oxpsb.azure.mongodb.net/<your-database-name>?retryWrites=true&w=majority