I have setup the angular code on my local machine. I need to know the version of the angular that I am using in the project. how can I easily find it in cmd prompt?
12 Answers
There are several ways you can do that:
- Go into
node_modules/@angular/core/package.json
and checkversion
field. If you need to use it in your code, you can import it from the
@angular/core
:import { VERSION } from '@angular/core';
Inspect the rendered DOM - Angular adds the version to the main component element:
<my-app ng-version="4.1.3">
For Angular 1 or 2 (but not for Angular 4+):
You can also open the console and go to the element tab on the developer tools of whatever browser you use.
Or
Type angular.version to access the Javascript object that holds angular version.
For Angular 4+ There is are the number of ways as listed below :
Write below code in the command prompt/or in the terminal in the VS Code.
- ng version or ng --version (See the attachment for the reference.)
- ng v
- ng -v
In the terminal you can find the angular version as shown in the attached image :
- You can also open the console and go to the element tab on the developer tools of whatever browser you use. As displayed in the below image :
5.Find the package.json file, You will find all the installed packages and their version.
- declare the variable named as 'VERSION', Import the dependencies.
import { VERSION } from '@angular/core';
// To display the version in the console.
console.log(VERSION.full);