Search code examples
angularangular-cli

How to get the Angular version?


I installed the @angular/cli package via npm using:

npm install -g @angular/cli

The version 1.4.2 of @angular/cli has been successfully installed. That is not the Angular version, but the CLI version.

After running ng new myapp how can I check which Angular version the created app is using? 2.x, 4.x?


Solution

  • ng version
    

    You installed angular cli globally (-g in the command). This means that you can type ng version into your command prompt. It may be more precise to do this when your command prompt is not within a npm controlled directory (you should type this in within directory you typed ng new myapp).

    A note to those who got here from Google: ng version will let you know which (coarse) version of Angular is referenced by the current directory. e.g. This directory appears to have angular 4.x (~4.3.0) installed.

    @angular/cli: 1.2.1
    node: 8.11.1
    os: win32 x64
    @angular/common: 4.3.0
    @angular/compiler: 4.3.0
    @angular/core: 4.3.0
    @angular/forms: 4.3.0
    @angular/http: 4.3.0
    @angular/platform-browser: 4.3.0
    @angular/platform-browser-dynamic: 4.3.0
    @angular/router: 4.3.0
    @angular/cli: 1.2.1
    @angular/compiler-cli: 4.3.0
    

    If you are not within a directory which has a packages.config, then you will get Angular: ....