What is the difference between dependencies and devDependencies?
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.