Skip to content

fix(@angular/cli): revert package.json changes if installation tasks fail during update#33563

Open
clydin wants to merge 2 commits into
angular:mainfrom
clydin:fix-update-rollback-package-json
Open

fix(@angular/cli): revert package.json changes if installation tasks fail during update#33563
clydin wants to merge 2 commits into
angular:mainfrom
clydin:fix-update-rollback-package-json

Conversation

@clydin

@clydin clydin commented Jul 14, 2026

Copy link
Copy Markdown
Member

When running the update command, if package manager installation fails (e.g., due to peer dependency conflicts or network issues), the project's package.json is left in an updated state but node_modules is missing or inconsistent.

To prevent leaving the workspace in a broken state, backup the original package.json before applying the update plan, and restore it from the backup if the installation tasks throw an error.

Closes #22162

@clydin clydin force-pushed the fix-update-rollback-package-json branch from d16c590 to c1c68a5 Compare July 14, 2026 14:33
…fail during update

When running the update command, if package manager installation fails (e.g., due to peer dependency conflicts or network issues), the project's package.json is left in an updated state but node_modules is missing or inconsistent.

To prevent leaving the workspace in a broken state, backup the original package.json before applying the update plan, and restore it from the backup if the installation tasks throw an error.
@clydin clydin force-pushed the fix-update-rollback-package-json branch from c1c68a5 to a560aa9 Compare July 14, 2026 14:36
…e managers

Other package managers (pnpm, yarn, bun) deterministically reconcile node_modules with the lockfile during installation, making full directory deletion unnecessary and slow.

Keep node_modules cleanup only for npm for now.
@clydin clydin marked this pull request as ready for review July 14, 2026 14:44

@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 introduces a backup and restore mechanism for the package.json file during the update process, ensuring it is restored to its original state if the update fails. Additionally, it optimizes the update process by skipping the node_modules cleaning task when the package manager is not npm. There are no review comments, and the changes are well-implemented, so I have no feedback to provide.

@clydin clydin added target: patch This PR is targeted for the next patch release target: minor This PR is targeted for the next minor release action: review The PR is still awaiting reviews from at least one requested reviewer and removed target: patch This PR is targeted for the next patch 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 deletes node_modules before ensuring it will succeed

1 participant