Upgrading to a more recent release or switching to an earlier version for compatibility reasons are two possible ways to change the Angular version in an existing project. The target version, the application's dependencies, and the current Angular version all influence the best course of action.

How to securely update or downgrade Angular is explained in this post.

Methods to Change the Angular Version

1. Use ng update for Angular Upgrades

For supported Angular upgrades, the recommended approach is to use the Angular CLI's ng update command.

To update Angular to the latest supported version:
ng update @angular/core@latest @angular/cli@latest

The Angular CLI can update package versions and run migration schematics required for the target Angular version.

For a specific version, use:
ng update @angular/core@<target_version> @angular/cli@<target_version>

For example:
ng update @angular/core@18 @angular/cli@18

This approach is generally preferable to manually changing package versions because Angular migrations can automatically update application code and configuration files.

2. Use Angular Migration Schematics

Angular provides migration schematics to help projects adapt to breaking changes between versions.

For example:
ng update @angular/core@<target_version>

Depending on the target version and the current project configuration, Angular may apply code migrations and dependency updates.

For larger version jumps, it is often safer to upgrade incrementally rather than attempting to move across several major versions at once.

For example:
Angular 14 → Angular 15 → Angular 16 → Angular 17

Incremental upgrades make it easier to identify compatibility problems and migration issues.

3. Manually Update Angular Dependencies
In some cases, you may need to manually specify Angular package versions in package.json.

For example:
{
  "dependencies": {
    "@angular/common": "15.2.0",
    "@angular/compiler": "15.2.0",
    "@angular/core": "15.2.0",
    "@angular/forms": "15.2.0",
    "@angular/platform-browser": "15.2.0",
    "@angular/platform-browser-dynamic": "15.2.0",
    "@angular/router": "15.2.0"
  }
}


After updating the dependencies, run:
npm install

The Angular CLI version should also be compatible with the Angular framework version used by the project.

Manual dependency updates can be useful when targeting a specific version, but they do not automatically apply migration steps. For major upgrades, ng update is generally the safer option.

4. Downgrading Angular
Downgrading Angular requires additional care because migration changes applied during a previous upgrade may not be automatically reversible.

For example, to install a specific Angular version:
npm install @angular/core@12 @angular/common@12 @angular/compiler@12

You should also ensure that all Angular framework packages use compatible versions.

For the Angular CLI:
npm install --save-dev @angular/cli@12

Depending on the application, you may also need to update packages such as:

  • @angular/forms
  • @angular/router
  • @angular/platform-browser
  • @angular/material
  • @angular/cdk
  • RxJS
  • TypeScript

After changing versions, remove and reinstall dependencies if necessary:
rm -rf node_modules package-lock.json
npm install

On Windows, you can remove the node_modules directory and package-lock.json manually or use the appropriate PowerShell commands.

Check Version Compatibility

Changing Angular versions is not limited to updating @angular/core. Angular projects depend on several related technologies that must remain compatible.

Before changing versions, check compatibility for:

  • Angular CLI
  • Angular packages
  • TypeScript
  • Node.js
  • RxJS
  • Angular Material
  • Angular CDK
  • Third-party Angular libraries

You can check the currently installed Angular versions by running:
ng version

You can also inspect the installed dependencies using:
npm list @angular/core

Best Practices When Changing Angular Versions

Follow these recommendations before upgrading or downgrading Angular:

Back Up the Project
Create a Git commit or backup before changing dependencies.

git add .
git commit -m "Backup before Angular version upgrade"

This makes it easier to revert if the migration introduces unexpected issues.

Upgrade Incrementally
For applications several major versions behind the current release, upgrading one major version at a time is often safer.

Review Breaking Changes
Major Angular versions can introduce breaking changes. Review the migration requirements before updating production applications.

Test the Application

After changing the Angular version, run the application and test suite:
npm test

You should also build the project:
ng build

This helps identify TypeScript, dependency, and compilation issues.
Check Third-Party Dependencies

Libraries used by the project may not immediately support the target Angular version. Verify compatibility before completing the migration.