Demystifying `devDependencies` and `dependencies`
Michael Scott Hertzberg
Posted on August 24, 2018
If you aren't familiar, devDependencies
and dependencies
are two properties that are added to package.json
when a package is installed as a development dependency or a production dependency, respectively.
In the npm ecosystem packages are installed and consumed by requiring or importing them in files, or run in the command-line as binaries. When an application is fed into a module bundler, like Webpack or Rollup, all required dependencies are pulled together and bundled (as the name suggests). You should ensure that these packages are present in dependencies
, as they're needed at runtime.
Development dependencies, or devDependencies
are packages that are consumed by requiring them in files or run as binaries, during the development phase. These are packages that are only necessary during development and not necessary for the production build. Some examples of packages that would only be required during development are babel plugins and presets, test runners and linter packages.
Alternatively, there is a dependency that is necessary in both production and development. In this case, it can be added to dependencies
, since dependencies
are available in both production and development.
I hope this explanation helps with you in deciding whether to --save-dev
or --save
that package, next time.
Posted on August 24, 2018
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.