Skip to content

fix(@angular/cli): resolve correct registry name when using npm alias syntax during update#33565

Open
clydin wants to merge 1 commit into
angular:mainfrom
clydin:fix-npm-alias-update
Open

fix(@angular/cli): resolve correct registry name when using npm alias syntax during update#33565
clydin wants to merge 1 commit into
angular:mainfrom
clydin:fix-npm-alias-update

Conversation

@clydin

@clydin clydin commented Jul 14, 2026

Copy link
Copy Markdown
Member

When a dependency uses the npm alias syntax (e.g. "@typescript/lib-dom": "npm:@types/web@^0.0.99"), ng update needs to fetch registry metadata for the actual package name (@types/web) rather than the local alias name (@typescript/lib-dom).

Introduce a RegistryClient helper to intercept and translate package names before querying registry metadata or manifest info, renaming the results back to the local alias name to maintain compatibility with the rest of the resolver logic.

Also update applyUpdatePlan to correctly parse and preserve alias prefixes when writing back to package.json, supporting scoped packages correctly.

Closes #25224

@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 adds support for resolving and updating npm packages that use the npm alias syntax (e.g., npm:alias-package@version). It updates the RegistryClient to handle registry name mapping, introduces a helper to parse alias names and ranges, and modifies the dependency update logic to preserve alias prefixes. A review comment points out a critical bug in the alias parsing logic where scoped packages without a version range (e.g., npm:@scope/pkg) would cause lastIndexOf('@') to return 0, leading to an invalid dependency entry. A suggestion is provided to ensure lastAtIndex > 0 to prevent this issue.

Comment thread packages/angular/cli/src/commands/update/update-resolver.ts Outdated
… syntax during update

When a dependency uses the npm alias syntax (e.g. "@typescript/lib-dom": "npm:@types/web@^0.0.99"), ng update needs to fetch registry metadata for the actual package name (@types/web) rather than the local alias name (@typescript/lib-dom).

Introduce a RegistryClient helper to intercept and translate package names before querying registry metadata or manifest info, renaming the results back to the local alias name to maintain compatibility with the rest of the resolver logic.

Also update applyUpdatePlan to correctly parse and preserve alias prefixes when writing back to package.json, supporting scoped packages correctly.
@clydin clydin force-pushed the fix-npm-alias-update branch from 2c8a600 to 2fdab50 Compare July 14, 2026 15:07
@clydin clydin added action: review The PR is still awaiting reviews from at least one requested reviewer target: minor This PR is targeted for the next minor release labels Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: review The PR is still awaiting reviews from at least one requested reviewer area: @angular/cli target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ng update not resolving the correct NPM package when using npm:<name> syntax as version range

1 participant