Skip to content

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

Merged
clydin merged 1 commit into
angular:mainfrom
clydin:fix-npm-alias-update
Jul 21, 2026
Merged

fix(@angular/cli): resolve correct registry name when using npm alias syntax during update#33565
clydin merged 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
@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
@clydin
clydin force-pushed the fix-npm-alias-update branch from 2fdab50 to 1bbbac6 Compare July 20, 2026 14:08
… 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 1bbbac6 to 539e9c9 Compare July 20, 2026 14:48
@clydin
clydin requested a review from alan-agius4 July 20, 2026 15:47
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jul 21, 2026
@clydin
clydin merged commit 6859d25 into angular:main Jul 21, 2026
40 checks passed
@clydin

clydin commented Jul 21, 2026

Copy link
Copy Markdown
Member Author

This PR was merged into the repository. The changes were merged into the following branches:

@clydin
clydin deleted the fix-npm-alias-update branch July 21, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker 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

2 participants