What is the difference between dependencies and devDependencies?
Short answer
dependencies are needed when the app runs in production (Express, a database driver). devDependencies are needed only to develop, test or build (Jest, ESLint, TypeScript, Webpack/Vite). Production installs can skip devDependencies to make images smaller and safer.
Example
"dependencies": { "express": "^4.19.2", "pg": "^8.12.0" },
"devDependencies": { "jest": "^29.7.0", "eslint": "^9.5.0", "typescript": "^5.5.0" }
npm install --save-dev jest # adds to devDependencies
npm ci --omit=dev # production: install only dependencies
Frontend twist
For a React/Vue app, almost everything is used only at build time — the final output is static files. So in a frontend Docker image, you install everything in the build stage and ship only dist/ (no node_modules at all).
Common bug
A package needed at runtime is wrongly put in devDependencies → works locally, crashes in production with Cannot find module.
What to say in the interview
"dependencies ship to production, devDependencies are for tests and builds. Our backend images use npm ci --omit=dev in the final stage, which reduces size and vulnerability count."