Docker and CI/CD · Middle · Question 26 of 75
Why install only production dependencies in the final image?
- ✓Correct answer: Dev tools add size and vulnerabilities but aren't needed to run
- 2Dev dependencies crash Node.js when NODE_ENV is production
- 3Registries reject images that contain test frameworks
Explanation
npm ci --omit=dev in the runtime stage (or copying a pruned node_modules from a builder) keeps TypeScript, test runners and linters out of production.