Development Dependencies (`devDependencies`)
Guide to devDependencies in package.json, why separating dev tools matters, how production builders prune devDependencies, and install commands.
The devDependencies field in package.json contains packages only needed during local development, testing, linting, and building. They are never executed in production runtimes.
What Belongs in devDependencies?
- Type Definitions:
@types/node,@types/react,@types/express - Compilers & Transpilers:
typescript,ts-node,tsx,@babel/core - Bundlers & Build Tools:
vite,esbuild,postcss,tailwindcss - Linters & Formatters:
eslint,prettier,biome - Testing Frameworks:
vitest,jest,playwright,cypress
Installing Development Dependencies
Use the -D (or --save-dev) flag:
# npm
npm install -D typescript @types/node
# pnpm
pnpm add -D vitest
# Yarn
yarn add -D prettierWhy the Separation Matters
-
Smaller Production Images & Faster Deployments: In Docker or cloud deployments, running:
npm ci --omit=devinstalls only runtime packages, reducing container image size and decreasing build times.
-
Security Isolation: Development tools often include heavier dependency trees and native binaries. Keeping them out of production containers reduces potential attack surfaces and CVE exposure.
-
Cleaner Dependency Graph for Published Libraries: When other developers install your npm package, npm never installs your
devDependencies. Only yourdependenciesandpeerDependenciesare resolved.
Related Guides
Runtime Dependencies (`dependencies`)
Guide to runtime dependencies in Node.js, when to install packages into dependencies, dependency resolution, and bundle size considerations.
Peer Dependencies (`peerDependencies`)
Guide to peerDependencies in package.json, plugin architectures, peerDependenciesMeta optional peers, and resolving conflicting peer dependencies.