Lesson 15 of 30
package.json
50% complete
Chapters
Chapter 15
package.json
Understand the package.json file and its role in Node.js projects.
Theory
package.json is an important configuration file in Node.js projects.
It can contain:
• Project name
• Version
• Description
• Scripts
• Dependencies
• Development dependencies
• Entry point
• Project metadata
The file allows NPM to understand and manage the project.
Example
Node.js Example
{
"name": "node-app",
"version": "1.0.0",
"scripts": {
"start": "node app.js"
},
"dependencies": {}
}Output
The project configuration and scripts are stored in package.json.
Practice
Create a package.json file and add a start script for your Node.js application.
Interview Questions
1.
What is package.json?
2.
What are dependencies?
3.
What is the scripts section used for?
Quick Quiz
Which option best matches this chapter?
A.Project configuration file
B.Database file
C.CSS configuration file
D.Operating system file
Answer: Project configuration file