0
0
Node.jsframework~5 mins

Environment configuration in Node.js - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
Aprocess.env['api_key']
Bprocess.API_KEY
Cenv.API_KEY
Dprocess.env.API_KEY
What file should you add to .gitignore to keep environment variables private?
Aconfig.js
B.env
Cpackage.json
DREADME.md
What does the dotenv package do in a Node.js project?
ALoads variables from .env into process.env
BCompiles JavaScript code
CManages database connections
DRuns tests automatically
Why is it better to use environment variables for configuration?
AThey automatically fix bugs
BThey make code run faster
CThey keep sensitive data out of code and allow easy changes
DThey reduce file size
Which command installs the dotenv package in a Node.js project?
Anpm install dotenv
Bnpm install express
Cnode dotenv
Dnpm start dotenv
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.