Field explanations
- scripts: commands used by local dev, build, test, and deploy platforms
- dependencies: runtime packages
- devDependencies: build, test, and type tooling
- type: controls ESM or CommonJS interpretation
Minimal template
{
"scripts": {
"dev": "vite",
"build": "vite build",
"start": "node server.js"
},
"dependencies": {},
"devDependencies": {}
}Common usage patterns
- Keep package.json small and reviewable
- Use comments only when the format supports them
- Commit example files with placeholder values
- Validate locally before deploying
Common errors
- Missing start script
- Dependency in devDependencies but needed at runtime
- ESM/CommonJS mismatch
- Package manager lockfile mismatch
Online validation
Validate syntax first, then compare behavior against your deploy target. For JSON-based configs, use the JSON formatter before debugging tool-specific behavior.