Skip to content

fix(@angular/cli): resolve the package name inside npm workspace members - #34302

Closed
Arthur031221 wants to merge 1 commit into
angular:mainfrom
Arthur031221:fix-ng-update-npm-workspace-member
Closed

Arthur031221 wants to merge 1 commit into
angular:mainfrom
Arthur031221:fix-ng-update-npm-workspace-member

Conversation

@Arthur031221

@Arthur031221 Arthur031221 commented Oct 10, 2026 •

Copy link
Copy Markdown

PR Checklist

PR Type

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: #32787

Running ng update @angular/core from an Angular app inside an npm workspace prints Found 0 dependencies. and fails with Package '@angular/core' is not a dependency. An outdated CLI hands over to a temporary install of the latest one, so upgrading from an older version fails the same way. The issue has 23 reactions and several users report the same failure.

getCurrentPackageName parses the output of npm pkg get name. Inside a workspace member npm prints an object keyed by the workspace name ({ "app": "app" }) instead of a string. That object was used as the package name, so parseNpmLikeDependencies never found the member's dependencies.

What is the new behavior?

The command output is only used if it's a string. Otherwise the name comes from the package.json in the current directory. ng update now lists the dependencies of the workspace member.

Added specs for the name and the dependencies of a workspace member. pnpm bazel test //packages/angular/cli:test passes.

Does this PR introduce a breaking change?

  • Yes
  • No

Assisted by Claude/Codex.

Closes #32787

Inside an npm workspace member, `npm pkg get name` prints an object keyed by
the workspace name instead of a JSON string. `getCurrentPackageName` returned
that object, so the workspace lookup in `parseNpmLikeDependencies` never
matched and `ng update` saw no dependencies for the member.

The name is now only taken from the command output when it is a string.
Otherwise it is read from the package.json of the current directory.

Fixes #32787

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the PackageManager to handle cases where npm prints an object keyed by the workspace name instead of a string. If the parsed output is not a string, it falls back to reading the package.json file. Unit tests have been added to verify this behavior and to test listing dependencies of an npm workspace member. I have no feedback to provide as there are no review comments.

@alan-agius4

Copy link
Copy Markdown
Collaborator

Thank you for the contribution! Closing in favor of #34308, which also prioritizes reading package.json directly to avoid spawning an extra package manager subprocess and handles single-entry workspace objects from npm pkg get name.

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.

v21.2.2 seems to be unable to handle npm workspaces

2 participants