how to find my angular version in my project?

JavascriptAngular

Javascript Problem Overview


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?

Javascript Solutions


Solution 1 - Javascript

There are several ways you can do that:

  1. Go into node_modules/@angular/core/package.json and check version field.
  2. If you need to use it in your code, you can import it from the @angular/core:

import { VERSION } from '@angular/core';

  1. Inspect the rendered DOM - Angular adds the version to the main component element:

<my-app ng-version="4.1.3">

Solution 2 - Javascript

try this command :

ng --version

It prints out Angular, Angular CLI, Node, Typescript versions etc.

Solution 3 - Javascript

> 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.

> 1. ng version or ng --version (See the attachment for the reference.) > 2. ng v > 3. ng -v

In the terminal you can find the angular version as shown in the attached image : enter image description here > 4. 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 :

enter image description here

> 5.Find the package.json file, You will find all the installed packages and their version.

> 6. 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); 

Solution 4 - Javascript

define VERSION variable and import version into it.

import { VERSION } from '@angular/core';

Now you can use VERSION variable in your code to print version For example,

console.log(VERSION.full); 

Solution 5 - Javascript

For Angular 2+ you can run this in the console:

document.querySelector('[ng-version]').getAttribute('ng-version')

For AngularJS 1.x:

angular.version.full

Solution 6 - Javascript

You can also find dependencies version details in package.json file as following:

enter image description here

Solution 7 - Javascript

ng --version command will show only the installed angular version in your computer instead of the actual project version.

if you really want to know the project version, Go to your project, use the below command

npm list -local

enter image description here

Another way, check package.json to know the angular version

enter image description here

Solution 8 - Javascript

  1. Browser > Inspect > Element >

    <.app-root _nghost-hey-c0="" ng-version="8.2.11">

  2. In terminal

    :> ng version
    :> ng --version
    :> ng -v

Solution 9 - Javascript

If you try to check angular version in the browser, for me only this worked Ctrl+Shift+i and paste below command in console:

document.querySelector('[ng-version]').getAttribute('ng-version')

ex:

enter image description here enter image description here

Solution 10 - Javascript

The best way to check which version of angular you're using is to launch your browser, right-click /inspect and look in the element tab. I found that to be most helpful.

Solution 11 - Javascript

app.component

import { Component, VERSION, } from '@angular/core';

name = 'Angular version' + VERSION.major;

app.component.html

<h5>{{name}}</h5>

Solution 12 - Javascript

you can use ng --version for angular version 7

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionVignesh KasthurisamyView Question on Stackoverflow
Solution 1 - JavascriptMax KoretskyiView Answer on Stackoverflow
Solution 2 - JavascriptMohamed Ali RACHIDView Answer on Stackoverflow
Solution 3 - JavascriptTrilok PathakView Answer on Stackoverflow
Solution 4 - JavascriptVirendra JadejaView Answer on Stackoverflow
Solution 5 - JavascriptNateowamiView Answer on Stackoverflow
Solution 6 - JavascriptImran JavedView Answer on Stackoverflow
Solution 7 - JavascriptSathiaView Answer on Stackoverflow
Solution 8 - JavascriptR M Shahidul Islam ShahedView Answer on Stackoverflow
Solution 9 - JavascriptEduard FlorinescuView Answer on Stackoverflow
Solution 10 - JavascriptJean-JosephView Answer on Stackoverflow
Solution 11 - JavascriptWilger M.AView Answer on Stackoverflow
Solution 12 - JavascriptminitechiView Answer on Stackoverflow