Package.json

The configuration file for Node.js projects that defines project metadata, dependencies, scripts, and other configuration settings.

Overview

package.json is the heart of any Node.js project. It contains metadata about your project, lists all dependencies, defines scripts for common tasks, and configures tools. This file is essential for package management with npm or yarn and makes your project reproducible across different environments.

Example

json
{
  "name": "my-react-app",
  "version": "1.0.0",
  "description": "A React application",
  "main": "index.js",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "test": "jest",
    "lint": "eslint src"
  },
  "dependencies": {
    "react": "^18.2.0",
    "react-dom": "^18.2.0"
  },
  "devDependencies": {
    "vite": "^5.0.0",
    "@vitejs/plugin-react": "^4.0.0",
    "eslint": "^8.0.0"
  },
  "keywords": ["react", "vite"],
  "author": "Your Name",
  "license": "MIT"
}

Key Points

  • Required for npm/yarn projects
  • Lists project dependencies
  • Defines npm scripts for automation
  • Specifies Node.js/npm version requirements
  • Contains project metadata

Learn More