Skip to content

fix(@angular/cli): recursively collect nested workspace dependencies in npm#33038

Closed
clydin wants to merge 1 commit intoangular:mainfrom
clydin:fix-npm-workspaces-update
Closed

fix(@angular/cli): recursively collect nested workspace dependencies in npm#33038
clydin wants to merge 1 commit intoangular:mainfrom
clydin:fix-npm-workspaces-update

Conversation

@clydin
Copy link
Copy Markdown
Member

@clydin clydin commented Apr 23, 2026

When running the update command in an npm workspace repository from within a workspace subdirectory, the CLI currently fails to detect hoisted dependencies. This occurs because npm list structures its workspace dependency output as nested items inside their respective top-level workspace entry, rather than as top-level items. The current parser was only reading the top-level items and consequently missed nested workspace dependencies.

This change updates the dependency parser to perform a breadth-first traversal of the JSON tree output of the package list command. By iteratively traversing the nested dependencies, the CLI can successfully resolve all installed packages within an npm workspaces monorepo.

@clydin clydin marked this pull request as ready for review April 23, 2026 15:39
Copy link
Copy Markdown

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

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 parseNpmLikeDependencies function to support nested dependencies through a breadth-first traversal and adds unit tests for workspace scenarios. Feedback was provided to optimize performance by avoiding O(N^2) operations with shift() and to ensure that shallower dependency versions are preserved rather than overwritten by nested ones.

Comment thread packages/angular/cli/src/package-managers/parsers.ts
…in npm

When running the update command in an npm workspace repository from within a workspace subdirectory, the CLI currently fails to detect hoisted dependencies. This occurs because npm list structures its workspace dependency output as nested items inside their respective top-level workspace entry, rather than as top-level items. The current parser was only reading the top-level items and consequently missed nested workspace dependencies.

This change updates the dependency parser to perform a breadth-first traversal of the JSON tree output of the package list command. By iteratively traversing the nested dependencies, the CLI can successfully resolve all installed packages within an npm workspaces monorepo.
@clydin clydin force-pushed the fix-npm-workspaces-update branch from 1401ec7 to 8532c3b Compare April 23, 2026 16:06
@clydin clydin closed this Apr 23, 2026
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.

1 participant