dependencies are needed at runtime. devDependencies are needed only to build and test. peerDependencies are packages the host project must provide.
dependencies are packages your code needs when it runs, such as express or pg. npm installs them whenever your package is installed, also when your package is a dependency of someone else's project.
devDependencies are needed only for development and building:
- test runners
- linters
- TypeScript
- type definitions
npm skips them when others install your package. It also skips them when you run npm install --omit=dev or npm ci --omit=dev. This keeps production images smaller.
peerDependencies say that your package works with a package the host project must provide. This is typical for a plugin and its framework. Example: a NestJS module peers on @nestjs/core. This avoids installing two copies of the framework. Since npm 7, npm installs peer dependencies automatically. If peer ranges conflict, npm fails with an ERESOLVE error.
- dependencies are needed at runtime and are installed transitively.
- devDependencies are build and test tools, left out with
--omit=dev. - peerDependencies are provided by the host project, as with plugins and their frameworks.
- Peer dependencies avoid duplicate copies of a framework.
- npm 7 and later install peers automatically and fail on conflicts.