Safeguard
Security Guides•

Should I migrate package managers and upgrade dependencies together?

No. Migrate first with versions preserved, then upgrade in a separate pull request, so each change is reviewable and any regression has one suspect.

Safeguard Security Team
4 min read

No. Do the migration with versions preserved, merge it, then upgrade dependencies in a separate pull request. When both land together, a regression has two suspects, the reviewer cannot tell a tool effect from a version effect, and you cannot roll back one without the other.

Two changes with different risks

A package manager migration changes how packages are resolved, fetched and installed. A dependency upgrade changes which code runs. Each deserves its own review question. For the migration: did anything move that should not have? For the upgrade: is the new code safe and compatible?

Mixed together, a lockfile diff of thousands of lines becomes unreviewable, and a real downgrade or a hostile new version hides in the noise.

How to preserve versions in the migration

Most tools give a way to carry the old pins across. The pnpm import command builds pnpm-lock.yaml from package-lock.json, npm-shrinkwrap.json or yarn.lock. The uv migration guide shows adding requirements with the old pinned file as constraints so existing versions are retained. Yarn Modern migrates the lockfile on the first install. For Maven to Gradle, the resolution rules differ, so compare the trees and pin differences, as in why versions change from Maven to Gradle.

The two pull requests

Pull requestGoalReview focus
1. MigrationSame versions, new toolingDiff of resolved lists, CI, registry settings, scripts
2. UpgradeNewer versions on purposeRelease notes, advisories, tests, maintainers

Between them, run the new setup for a short period. If something odd appears in production, you know the tool change is the only change.

Steps

  1. Branch from the main branch with a green build.
  2. Migrate with versions preserved.
  3. Verify with a diff (see verify resolved versions after switching package managers).
  4. Merge and ship.
  5. Start upgrades. The uv documentation notes that a lockfile is not considered outdated when new releases appear, so nothing upgrades until you ask. Use targeted upgrades for security fixes first.
  6. For the upgrade itself, see what to check in a lockfile diff during code review.

When you must combine them

Sometimes the old tool cannot resolve a safe version, and the migration is the fix. Then say so in the pull request, list the intended upgrades by name, and keep every other version fixed. A short, explicit allow list of changes keeps the review honest.

Urgent security fixes during a migration

If an advisory lands mid migration, patch on the main branch using the old tooling and merge it into the migration branch. Do not fold the fix into the migration. See lockfile only fix versus manifest change review.

Try it yourself

Click through it at your own pace, or open it full screen. See how a fix for a specific vulnerable version is proposed as its own change, which is the shape the second pull request should take.

Safeguard's autonomous remediation can open fix pull requests; it is off by default and every category is on Manual, so changes need your approval. A free scan is at gold.safeguard.sh/scan.

Quick check

Is one big pull request faster?

It is faster to open and slower to review and debug. Two small ones usually finish sooner.

What if a security fix is urgent mid migration?

Ship it separately on the main branch and merge it into the migration branch afterwards.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.