What is the difference between dependencies and devDependencies?
Why Interviewers Ask This
This is a classic screening question for Node.js roles. Hiring managers ask it early in interviews to gauge your baseline understanding and determine if you can communicate technical concepts clearly.
Answer
dependencies are packages required for the application to run in production — they are needed at runtime. Examples: express, mongoose, axios, jsonwebtoken. Install with npm install <package>. devDependencies are packages only needed during development and build processes — not in production. Examples: testing frameworks (jest, mocha), linters (eslint), transpilers (babel, typescript), bundlers (webpack, vite), and test utilities (supertest). Install with npm install --save-dev <package>. When deploying, run npm install --production (or set NODE_ENV=production) to install only dependencies, keeping the production installation lean. peerDependencies are a third type — they specify a compatibility requirement that the consumer of your package must install themselves (e.g., a React component library lists react as a peerDependency). optionalDependencies are installed if possible but not required for the package to work.
Pro Tip
Demonstrate both theoretical understanding and practical experience. Say what it is, then give an example of how you actually used it in a Node.js codebase.