DEV Community

Cover image for 3 Methods to Check the Angular Version
OpenReplay Tech Blog
OpenReplay Tech Blog

Posted on • Originally published at blog.openreplay.com

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
Enter fullscreen mode Exit fullscreen mode

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""
     }
   }
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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

What if the 'ng version' command doesn't work?
Ensure you have the Angular CLI installed globally by running 'npm install -g @angular/cli' and retry the command.

Can I use these methods for older AngularJS versions?
No. AngularJS (1.x) does not use the same tools. Check the version through the angular.version.full property in the console instead.

Why is the Angular version important?
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.

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay