How-To

How To Check Angular Version

Knowing the version of Angular you are working with is crucial for development, compatibility, and troubleshooting purposes. Angular, being a widely used framework for building web applications, frequently updates its versions, introducing new features, deprecations, and performance improvements. Whether you are maintaining an existing project, integrating third-party libraries, or starting a new application, being able to quickly check the Angular version ensures that your codebase is aligned with the correct framework features. This is particularly important when collaborating in teams, upgrading dependencies, or debugging issues that may depend on version-specific behaviors.

Checking Angular Version Using Angular CLI

The Angular Command Line Interface (CLI) is the most common and convenient tool for interacting with Angular projects. It provides commands to build, serve, and manage Angular applications, as well as checking framework information.

Using the ng version Command

To check the Angular version, navigate to your project directory in the terminal and run the following command

  • ng version

This command outputs detailed information about your Angular project, including

  • Angular CLI version
  • Angular framework packages, such as core, compiler, and common
  • Node.js version
  • Operating system details

The output looks something like this

Angular CLI 15.0.0 Node 18.12.1 Package Manager npm 9.5.0 OS linux x64Angular 15.0.0... animations, common, compiler, compiler-cli, core, forms, platform-browser... platform-browser-dynamic, router

This method is highly recommended because it provides both the Angular version and the CLI version, helping you understand the full development environment.

Checking Angular Version Without CLI

If the Angular CLI is not installed globally or you want to check the version programmatically, you can inspect thepackage.jsonfile in your project. This file lists all dependencies and their versions. Look for the following entries underdependencies

  • @angular/core
  • @angular/cli
  • @angular/compiler

The version number next to@angular/coreindicates the Angular framework version. For example

dependencies" { "@angular/core" "^15.0.0", "@angular/common" "^15.0.0", "@angular/compiler" "^15.0.0" }

Checking thepackage.jsonfile is particularly useful when the CLI is not installed globally or when you need to verify the version for CI/CD pipelines.

Checking Angular Version in Node Modules

You can also check the installed Angular version directly from thenode_modulesfolder. This method ensures you are seeing the version that is currently being used in the project, not just the version listed inpackage.json.

Using npm list Command

Run the following command in the terminal within your project directory

  • npm list @angular/core

This command outputs the installed version of Angular core and its dependencies. The output looks like this

project-name@1.0.0 /path/to/project ââ€â€ @angular/core@15.0.0

This approach is helpful to confirm the actual installed version, which may differ from the version specified inpackage.jsonif dependencies were updated or installed differently.

Checking Angular Version in the Browser

Sometimes it is necessary to verify the Angular version of a live application directly in the browser. Angular applications expose version information through certain global objects.

Using ng.probe or ng Version Check

Open the browser’s developer console and try typing

  • ng.version.full

This will return the full Angular version if Angular DevTools or the Angular global object is available. Note that some production builds disable this object, so it may not always be accessible.

Using Angular DevTools

Angular DevTools is a browser extension that provides insights into Angular applications, including performance profiling and component inspection. Once installed, open the DevTools panel while on an Angular app page, and it will display the Angular version among other useful information about the app structure. This method is convenient for developers who need a visual tool to inspect Angular applications.

Benefits of Knowing the Angular Version

  • Ensures compatibility with third-party libraries and modules.
  • Helps in debugging version-specific issues.
  • Assists in planning upgrades or migrations to newer Angular versions.
  • Supports team collaboration by maintaining consistent development environments.
  • Improves troubleshooting by comparing project and installed versions.

Updating or Managing Angular Versions

After checking the Angular version, you may need to update or align versions across different projects. The Angular CLI provides commands to update dependencies easily

  • ng update @angular/cli @angular/core

This command updates both the CLI and core framework packages to the latest compatible versions, maintaining project stability. You can also specify a target version for controlled upgrades, for example

  • ng update @angular/cli@15 @angular/core@15

Regularly monitoring and updating Angular versions helps maintain security, performance, and access to new features.

Checking the Angular version is a simple yet essential task for any developer working with Angular applications. Whether you use theng versioncommand, inspectpackage.json, use npm commands, or check through Angular DevTools in the browser, each method provides valuable information about your development environment. Understanding the version helps ensure compatibility, enables proper debugging, and assists in planning upgrades. By consistently checking and managing Angular versions, developers can maintain stable, efficient, and modern web applications while avoiding potential version conflicts or dependency issues. Keeping track of Angular versions is a small step that greatly contributes to successful development and project maintenance.