Member-only story
An In-Depth Explanation of package.json’s Dependencies
Dependencies, devDependencies, and peerDependencies: What do they mean?
If you use npm (Node Package Manager) to manage a JavaScript project, it is vital to structure dependencies correctly in your package.json
. Just one npm command, npm install
, can install all dependent packages based on the specification.
With the emerging micro-frontends and monorepo approaches, the interrelationship between dependencies becomes ever more challenging.
This article describes different types of dependencies in package.json
, and shows a few solutions we’ve adopted regarding peerDependencies
issues during our product development. In the end, we talk about external dependencies.
Types of Dependencies
There are five types of dependencies defined in the npm documentation:
1. Normal dependencies
The normal dependencies: These dependent packages serve as libraries to make a project work.
The final product must be bundled with these packages, which might be frameworks (such as React, Angular, Vue, etc.), utilities (such as i18next, Lodash, axios, etc.), and subcomponents in your organization.