What is package.json
Great question! package.json is one of the most important files in any Node.js or JavaScript project — especially when using npm.
📦 What is package.json?
It’s a configuration file that stores metadata about your project, like:
• Project name, version, and description
• Which packages (dependencies) your app needs
• Scripts you can run (like npm run dev)
• Project author, license, and more
🧠 Why is it important?
Because it tells npm (and other devs) how to install, run, and manage your project.
🔍 Example package.json:
{
"name": "my-app",
"version": "1.0.0",
"description": "A cool project",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"react": "^18.2.0"
},
"devDependencies": {
"vite": "^5.0.0"
}
}
🛠️ Key Sections:
| Section | What it does |
| name / version | Basic info about your project |
| scripts | Custom commands you can run with npm run |
| dependencies | Packages required to run your app |
| devDependencies | Packages needed only during development |
| license / author | Legal info and authorship |
✅ Common commands using package.json:
npm install # Installs all listed dependencies
npm run dev # Runs the "dev" script
npm run build # Runs the "build" script