← Back to Angular, page 7

angular-0132 · Medium mid

How do you upgrade an Angular application to a new major version safely, and how does ng update work?

Upgrade one major version at a time with ng update, starting from a clean git state. The CLI runs migration schematics that rewrite your code for breaking changes, and the official update guide lists manual steps. Update Angular packages together, then third party libraries, run the tests, and fix deprecations before the next step.

Full answer

Angular releases a major version about every six months, with minor versions and patches between. Each major version comes with automated migrations.

Process:

  1. Prepare: commit or stash your work, make sure tests and the build pass, and read the official "Angular update guide" (update.angular.dev), which gives steps for your from and to versions and your app complexity.
  2. Update one major version at a time: ng update @angular/core@20 @angular/cli@20. Skipping majors is not supported by the schematics. The command checks peer dependencies, installs the new versions, and runs migration schematics, which edit your code (for example moving to the new control flow, standalone components, or renamed APIs). Review the diff.
  3. Update dependent libraries to compatible versions: Angular Material and CDK (ng update @angular/material@20), NgRx, and others. ng update without arguments lists what can be updated.
  4. Update TypeScript, Node and zone.js versions as required by the guide. Each Angular version supports a range of Node and TypeScript versions.
  5. Build, run unit and end to end tests, and test manually in the browser. Fix compile errors and warnings.
  6. Replace deprecated APIs at your own pace. The team keeps deprecated APIs for at least two major versions, and migrations help.
  7. Commit each major step separately, so problems are easy to find.

Useful flags: --force ignores peer dependency problems (use with care), --allow-dirty runs with uncommitted changes, --create-commits makes a commit for each migration, and --migrate-only --from=19.0.0 --to=20.0.0 reruns migrations only.

Optional migrations that are not automatic: ng generate @angular/core:standalone, @angular/core:control-flow, @angular/core:signal-input-migration, and @angular/core:inject. They modernise code gradually.

Support policy: each major has about 18 months of support (6 active, 12 long term). Planning upgrades twice a year is cheaper than a large jump after several years. When the project is very old, upgrade step by step, and consider a time-boxed rewrite of parts that cannot be migrated.

typescript
// file: package.excerpt.json
{
  "scripts": {
    "update:core": "ng update @angular/core@20 @angular/cli@20",
    "update:material": "ng update @angular/material@20",
    "migrate:standalone": "ng generate @angular/core:standalone",
    "migrate:control-flow": "ng generate @angular/core:control-flow",
    "migrate:signal-inputs": "ng generate @angular/core:signal-input-migration",
    "migrate:inject": "ng generate @angular/core:inject",
    "check:versions": "ng version"
  }
}

Angular CLI 20. This is a process answer. The snippet lists the commands as npm scripts in a package.json excerpt, and the commands were not executed against an old project here.

Key points

  • Upgrade one major version at a time with `ng update`, from a clean git state.
  • Migration schematics edit code. Review the diff. Follow the official update guide.
  • Update Material, NgRx and other libraries, then TypeScript and Node as required.
  • Test each step and commit separately. Upgrade regularly.

Common mistakes

  • Jumping several majors at once.
  • Using `--force` to skip peer dependency warnings without checking.
  • Running the update with uncommitted work.

Follow-ups

  • How would you handle a library that has no version for the new Angular?
  • What does `--migrate-only` do?
  • How long is an Angular version supported?

Tips

  • Mention the update guide website. It shows that you use official tools.
  • Describe a safe order: Angular, libraries, tests.
  • Mention the optional migration schematics.

Evaluation rubric

  • Describes a safe step by step process.
  • Knows what ng update does and key flags.
  • Understands support policy and regular upgrades.