Skip to content

fix(js): resolve catalog references in pruned package.json output#35805

Open
polygraph-snapshot-app[bot] wants to merge 1 commit into
masterfrom
gh-35419
Open

fix(js): resolve catalog references in pruned package.json output#35805
polygraph-snapshot-app[bot] wants to merge 1 commit into
masterfrom
gh-35419

Conversation

@polygraph-snapshot-app
Copy link
Copy Markdown
Contributor

Current Behavior

When using the @nx/js:prune-lockfile executor in a workspace that uses catalog: references (pnpm or yarn), the emitted dist/package.json still contains the raw catalog: specifiers:

{
  "dependencies": {
    "@nestjs/common": "catalog:",
    "zod": "catalog:"
  }
}

The emitted dist/pnpm-lock.yaml correctly contains resolved versions (e.g. ^11.0.0), because the lockfile path already resolves catalog references internally via getCatalogManager().resolveCatalogReference().

The mismatch causes pnpm install --frozen-lockfile to fail with ERR_PNPM_OUTDATED_LOCKFILE:

ERR_PNPM_OUTDATED_LOCKFILE  Cannot install with "frozen-lockfile" because pnpm-lock.yaml is not up to date with package.json

  Failure reason:
  specifiers in the lockfile don't match specifiers in package.json:
* dependencies are mismatched:
  - @nestjs/common (lockfile: ^11.0.0, manifest: catalog:)
  - zod (lockfile: ^4.3.6, manifest: catalog:)

Expected Behavior

The emitted dist/package.json has catalog: references resolved to real version strings, matching what the pruned lockfile already contains, so pnpm install --frozen-lockfile succeeds.

Implementation Details

Adds a pure resolveCatalogReferences() helper in the prune-lockfile executor that runs after the project's package.json is read and before the lockfile is generated. It uses the existing getCatalogManager() utility (exposed via @nx/devkit/internal) and resolves catalog references across dependencies, optionalDependencies, devDependencies, and peerDependencies — mirroring how pnpm-parser.ts handles them when producing the lockfile.

  • No-op for package managers without catalog support (npm/bun).
  • Works for both pnpm and yarn Berry catalogs.
  • Throws on unresolvable references, matching the lockfile path's behavior.

Related Issue(s)

Fixes #35419


View session information ↗

@netlify
Copy link
Copy Markdown

netlify Bot commented May 26, 2026

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit 684a349
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/6a15b30bc841df00084ee28e
😎 Deploy Preview https://deploy-preview-35805--nx-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 26, 2026

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 684a349
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/6a15b30b2d89cb0008a8c4c8
😎 Deploy Preview https://deploy-preview-35805--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@leosvelperez leosvelperez self-assigned this May 26, 2026
@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud Bot commented May 26, 2026

View your CI Pipeline Execution ↗ for commit 684a349

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 18m 12s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 4s View ↗
nx-cloud record -- pnpm nx-cloud conformance:check ✅ Succeeded 16s View ↗
nx build workspace-plugin ✅ Succeeded <1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 19s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 4s View ↗

☁️ Nx Cloud last updated this comment at 2026-05-26 16:03:47 UTC

@leosvelperez leosvelperez marked this pull request as ready for review May 26, 2026 16:28
@leosvelperez leosvelperez requested a review from a team as a code owner May 26, 2026 16:28
@leosvelperez leosvelperez requested a review from MaxKless May 26, 2026 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(js): prune-lockfile emits catalog: specifiers in package.json causing ERR_PNPM_OUTDATED_LOCKFILE in Docker

1 participant