← Back to list

Dependencies in package.json

In node.js project’s package.json file, there are three sections for defining dependencies: dependencies , peerDependencies , and…

Pratyush Mani Manav · 2023-09-05 07:52 · 52 claps · 1.4 min read
#nodejs #react #angular #front-end-development #dependencies
Open on Medium ↗
Wiki topics: CRY · Crypto & Web3 🌐 · Web Development

Dependencies in package.json

In node.js project’s package.json file, there are three sections for defining dependencies: dependencies , peerDependencies , and devdependencies . These dependencies are used to specify the external libraries and modules that your project relies on. These dependencies can be anything from utility libraries to web frameworks, and they’re essential for building complex applications efficiently.

In this blog, we will explore dependency types, how to classify them, and the side effects of wrongly classified dependencies.

  1. Dependencies: Dependencies are also known as runtime dependencies. These are represented in dependencies the section in package.json the file. Packages mentioned in dependencies sections are required at run time to run the application. When you run npm install , it gets stored in node_modules the directory, and when you publish your package to npm registry , these dependencies also get included.
  2. DevDependencies: Dev dependencies are the packages that are required for development. These packages are included in thedevDependenciessection in package.json the file. These packages are not required to run the application, but they are required for building, testing, and linting the code during development. When you install a package as devDependencies , it is also stored in node_modules the directory. But unlike dependencies , devDependencies are not included when you publish your package to the npm registry .
  3. PeerDependencies: Peer dependencies are the packages that are required to be installed in the user’s environment. These packages are included in thepeerDependencies section in the package.json file. These packages are not installed when you run npm install , but the user is expected to install them manually. Peer dependencies are typically used when you are building a package that is meant to be used as a library or a plugin. By specifying your dependency as a peer dependency you can ensure that your package is compatible with different versions of its dependencies.

Effects of putting devDependencies into dependencies: If we move devDependencies into dependencies , your application will carry these dependencies into the production environment. This could have the following potential implications:

  • Increased Bundle size
  • Security Risks
  • Unused code
  • Incompatibility
  • Deployment Overhead

It is generally recommended to keep development dependencies separated from production dependencies by keeping them in respective sections. This ensures that your production environment only contains the necessary packages for your application to run smoothly.


메타데이터
post_id
1e079fb9d19b
slug
dependencies-in-package-json-1e079fb9d19b
url
https://medium.com/@pmmanav/dependencies-in-package-json-1e079fb9d19b
canonical_url
https://medium.com/@pmmanav/dependencies-in-package-json-1e079fb9d19b
author_url
https://medium.com/@pmmanav
status
ok
fetched_at
2026-07-25 07:06:12