Comparing Packages Across Monorepo Workspaces
Compare package.json files from different workspaces in a monorepo to find version inconsistencies and missing shared dependencies.
Detailed Explanation
Monorepo Package Consistency
In monorepos (using npm workspaces, Yarn workspaces, pnpm workspaces, or Turborepo), each workspace has its own package.json. Keeping dependency versions consistent across workspaces prevents subtle bugs caused by version mismatches.
Common inconsistency patterns
# packages/web/package.json vs packages/api/package.json
dependencies:
~ zod: ^3.21.0 -> ^3.22.0 [MINOR]
~ typescript: ^5.2.0 -> ^5.3.0 [MINOR]
+ @prisma/client: ^5.0.0 [ADDED - only in api]
- react: ^18.2.0 [REMOVED - only in web]
Why consistency matters
| Issue | Consequence |
|---|---|
| Different TypeScript versions | Incompatible type definitions across packages |
| Mismatched shared library versions | Runtime errors when passing data between packages |
| Missing peer dependencies | Warnings or silent failures |
| Duplicate dependencies | Increased node_modules size |
How to use the diff for monorepo auditing
- Copy the
package.jsonfrom workspace A (e.g.,packages/web/package.json) - Paste it into the left panel
- Copy the
package.jsonfrom workspace B (e.g.,packages/api/package.json) - Paste it into the right panel
- Click Compare and filter to Changed only to see version discrepancies
Fixing inconsistencies
After identifying mismatches, you can:
- Use the root
package.jsonoverrides field (npm) orresolutionsfield (Yarn) to enforce versions - Create a shared
tsconfig.base.jsonthat all workspaces extend - Use tools like
syncpackto automatically align versions
Use Case
A monorepo maintainer notices flaky tests in CI and suspects version mismatches between the frontend and backend workspaces. They compare both package.json files to find that the shared validation library has different versions in each workspace.
Try It — Package.json Diff
Related Topics
Major Version Upgrade: Detecting Breaking Changes
Version Analysis
Tracking New Dependencies Added to a Project
Dependency Management
Analyzing Peer Dependency Changes
Dependency Management
Aligning Dependencies After Lock File Conflicts
Dependency Management
Comparing devDependency Changes Separately
Development Tooling