What is the difference between devDependencies and dependencies in package.json?

 

🔹 dependencies

Packages your app needs to run in production.

  • Used in the app's runtime code

  • Installed on both development and production environments

  • Example: Frameworks, HTTP clients, database drivers

Example:

"dependencies": {
"express": "^4.18.2", "axios": "^1.6.0" }

🔸 devDependencies

Packages your app only needs during development (not in production).

  • Used only for building, testing, linting, compiling

  • Installed only in development, not in production (NODE_ENV=production)

  • Example: TypeScript, Webpack, ESLint, test libraries

Example:

"devDependencies": {
"typescript": "^5.4.0", "eslint": "^8.54.0", "jest": "^29.7.0" }

Dev (write code) Build (transpile/bundle) Run (prod server)
dependencies
devDependencies

No comments:

Post a Comment