Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is the purpose of the package.json file in a Node.js project?
The package.json file stores important information about the project like its name, version, dependencies, scripts, and metadata. It helps manage the project and its packages easily.
Click to reveal answer
beginner
What command do you run to start npm initialization and create a package.json file?
You run npm init to start the interactive process that helps you create a package.json file step-by-step.
Click to reveal answer
beginner
What does the npm init -y command do?
It creates a package.json file with default values automatically, skipping the questions asked during normal npm init.
Click to reveal answer
beginner
Name two common fields you will find in a package.json file.
Two common fields are dependencies which lists packages your project needs, and scripts which defines commands you can run like npm start.
Click to reveal answer
intermediate
Why is it important to keep package.json under version control (like Git)?
Because it tracks the exact packages and versions your project uses, so others can install the same setup and your project stays consistent.
Click to reveal answer
Which command creates a package.json file with default answers?
Anpm start
Bnpm init -y
Cnpm install
Dnpm run
✗ Incorrect
npm init -y quickly creates package.json with default values.
What does the dependencies field in package.json list?
APackages the project needs to work
BProject metadata
CUser information
DScripts to run
✗ Incorrect
dependencies lists packages your project needs to run.
Which command starts the interactive npm initialization process?
Anpm install
Bnpm run
Cnpm start
Dnpm init
✗ Incorrect
npm init starts the step-by-step setup for package.json.
Where should you keep your package.json file for collaboration?
AOnly on your local machine
BIn a private folder
CIn version control like Git
DOn a USB drive
✗ Incorrect
Keeping package.json in version control helps others use the same setup.
What is NOT typically included in package.json?
AInstalled package code
BProject version
CProject name
DScripts to run
✗ Incorrect
package.json lists packages but does not contain their code.
Explain the purpose of npm init and what happens when you run it.
Think about how npm helps set up your project info.
You got /5 concepts.
Describe why the package.json file is important for sharing your Node.js project with others.
Consider what happens when someone else wants to run your project.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of running npm init in a Node.js project?
easy
A. To start the Node.js server automatically
B. To install all dependencies listed in package.json
C. To create a package.json file that manages project info and dependencies
D. To update Node.js to the latest version
Solution
Step 1: Understand what npm init does
Running npm init sets up a new Node.js project by creating a package.json file.
Step 2: Identify the role of package.json
This file stores project metadata, scripts, and dependencies for easy management.
Final Answer:
To create a package.json file that manages project info and dependencies -> Option C
Quick Check:
npm init creates package.json = A [OK]
Hint: Remember: npm init sets up package.json [OK]
Common Mistakes:
Confusing npm init with npm install
Thinking npm init starts the server
Assuming npm init updates Node.js
2. Which command quickly creates a package.json file with default values without asking questions?
easy
A. npm init -y
B. npm init
C. npm install
D. npm start
Solution
Step 1: Recall npm init options
npm init runs an interactive setup asking questions, while npm init -y skips questions and uses defaults.
Step 2: Identify the command for quick setup
The -y flag means "yes" to all prompts, creating package.json immediately.
Final Answer:
npm init -y -> Option A
Quick Check:
npm init -y = quick default package.json [OK]
Hint: Use -y flag for instant package.json creation [OK]