Back

3 Methods to Check the Angular Version

3 Methods to Check the Angular Version

Whether you’re debugging an issue or preparing for an upgrade, knowing your Angular version is essential. This quick guide walks you through three simple methods to check the Angular version of your project. By the end, you’ll have the tools to identify it quickly and accurately.

Key Takeaways

  • You can check the Angular version using the CLI, package.json, or inspecting the browser console.
  • Each method works best in different scenarios, depending on your project setup.
  • Knowing your Angular version ensures compatibility with tools and dependencies.

1. Check Using the Angular CLI

The Angular CLI provides a straightforward way to check your project’s version:

  1. Open a terminal.
  2. Navigate to the root directory of your Angular project.
  3. Run the following command:
   ng version

This displays detailed information, including the Angular version, CLI version, and dependencies.

When to Use This Method

Use the CLI if you’re working actively on the project or troubleshooting locally. It’s quick and reliable.

2. Inspect the package.json File

Your package.json file stores version information for Angular and its dependencies. Here’s how to find it:

  1. Open the package.json file in your project directory.
  2. Look for @angular/core under the dependencies section:
   {
     ""dependencies"": {
       ""@angular/core"": ""^15.2.0""
     }
   }

The number after @angular/core (e.g., 15.2.0) is your Angular version.

When to Use This Method

This is helpful when you don’t have the CLI installed or need to verify the version remotely (e.g., through version control).

3. Use the Browser Console

If the project is running in the browser, you can inspect the Angular version directly from the console:

  1. Open the browser’s developer tools (usually F12 or right-click → Inspect).
  2. Navigate to the ""Console"" tab.
  3. Type and run the following command:
   ng.probe(document.body).injector.get(ng.coreTokens.VERSION).full

This will output the Angular version currently in use.

When to Use This Method

This method is ideal when accessing a deployed Angular application where you don’t have access to the source files or CLI.

FAQs

Ensure you have the Angular CLI installed globally by running 'npm install -g @angular/cli' and retry the command.

No. AngularJS (1.x) does not use the same tools. Check the version through the `angular.version.full` property in the console instead.

It ensures compatibility with dependencies, helps troubleshoot issues, and determines the right documentation to follow.

Conclusion

Identifying the Angular version is straightforward using the CLI, package.json, or browser console. Choose the method that fits your scenario and ensure your projects remain compatible and maintainable.

Listen to your bugs 🧘, with OpenReplay

See how users use your app and resolve issues fast.
Loved by thousands of developers