Syncpack

14.3.0 · active · verified Sun Apr 19

Syncpack is a robust CLI tool and library designed to enforce consistent dependency versions across large JavaScript and TypeScript monorepos. Currently at stable version 14.3.0, it maintains a regular and active release cadence with several updates, including patches and minor features, issued monthly. Its core functionality includes linting for version inconsistencies, automatically fixing them, and updating dependencies to the latest available versions while preserving semver ranges. Syncpack differentiates itself through its deep integration with various monorepo tools like Lerna, Nx, and pnpm, and its recent rewrite in Rust for version 14 significantly improved performance and introduced a new, more modular API. It is widely adopted by organizations such as AWS, Microsoft, and Vercel for maintaining their large-scale projects.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates setting up a minimal monorepo, installing Syncpack, identifying inconsistent dependency versions with `lint`, automatically fixing them with `fix`, and then updating all dependencies to their latest compatible versions using `update`.

npx cross-env MY_MONOREPO_ROOT="$(pwd)" bash -c '
  # 1. Initialize a new monorepo project
  mkdir my-syncpack-demo && cd my-syncpack-demo
  npm init -y &>/dev/null
  mkdir -p packages/app-a packages/app-b
  echo "{ \"name\": \"app-a\", \"version\": \"1.0.0\", \"dependencies\": { \"react\": \"18.2.0\", \"lodash\": \"^4.17.21\" } }" > packages/app-a/package.json
  echo "{ \"name\": \"app-b\", \"version\": \"1.0.0\", \"dependencies\": { \"react\": \"^18.0.0\", \"lodash\": \"4.17.15\" } }" > packages/app-b/package.json
  echo "{ \"name\": \"my-monorepo-root\", \"private\": true, \"workspaces\": [\"packages/*\"] }" > package.json

  echo "\n--- Created initial monorepo structure with inconsistent lodash versions ---"
  cat packages/app-a/package.json
  cat packages/app-b/package.json

  # 2. Install syncpack as a dev dependency in the root
  npm install --save-dev syncpack &>/dev/null
  echo "\n--- syncpack installed ---"

  # 3. Check for dependency inconsistencies
  echo "\n--- Running syncpack lint ---"
  npx syncpack lint || true # lint exits with non-zero on issues

  # 4. Fix inconsistencies across the monorepo
  echo "\n--- Running syncpack fix ---"
  npx syncpack fix

  # 5. Review the changes
  echo "\n--- package.json files after syncpack fix ---"
  cat packages/app-a/package.json
  cat packages/app-b/package.json

  # 6. (Optional) Update all dependencies to their latest compatible versions
  echo "\n--- Running syncpack update --target latest ---"
  npx syncpack update --target latest --dependency-types prod,dev

  cd $MY_MONOREPO_ROOT && rm -rf my-syncpack-demo
'

view raw JSON →