Recall & Review
beginner
What is environment configuration in Node.js?
Environment configuration means setting up variables and settings that control how your Node.js app runs in different places, like development or production.
Click to reveal answer
beginner
Why use environment variables instead of hardcoding values?
Environment variables keep sensitive info like passwords safe and let you change settings without changing code, making your app flexible and secure.Click to reveal answer
beginner
What file is commonly used to store environment variables locally in Node.js projects?
The .env file stores environment variables locally. It is simple text with key=value pairs and should not be shared publicly.
Click to reveal answer
beginner
How do you access an environment variable named PORT in Node.js?
Use process.env.PORT to get the value of the PORT environment variable in your Node.js code.
Click to reveal answer
beginner
What is the purpose of the dotenv package in Node.js?
The dotenv package loads variables from a .env file into process.env so your app can use them easily during development.
Click to reveal answer
Which of these is the correct way to access an environment variable named API_KEY in Node.js?
✗ Incorrect
Environment variables are accessed using process.env.VARIABLE_NAME with exact case.
What file should you add to .gitignore to keep environment variables private?
✗ Incorrect
The .env file contains sensitive info and should not be pushed to public repositories.
What does the dotenv package do in a Node.js project?
✗ Incorrect
Dotenv reads .env files and sets environment variables for your app.
Why is it better to use environment variables for configuration?
✗ Incorrect
Environment variables separate config from code, improving security and flexibility.
Which command installs the dotenv package in a Node.js project?
✗ Incorrect
Use npm install dotenv to add the dotenv package to your project.
Explain how environment variables help manage different settings for development and production in Node.js.
Think about how you might run your app on your computer vs on a server.
You got /4 concepts.
Describe the steps to set up environment configuration using a .env file and the dotenv package in a Node.js project.
Imagine you want to keep your secret keys safe and easy to change.
You got /5 concepts.