Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing Angular 5 through which CLI version

I am using Ubuntu 18 and want to start the Angular 5 project and therefore I installed Node, npm, TypeScript and finally the latest stable Angular CLI by below command,

sudo npm install -g @angular/cli

So, by default it is downloading the latest stable Angular CLI, which is now 6.1.3 and it's by default serve the Angular 6 version instead of Angular 5, which is my requirement.

There after I searched so many pages on same to get the right CLI version for the latest version 5.2.11 for Angular 5.

Also watched many post but many are from last year 2017, when the Angular 5 were newly published.

So my issue is to get Angular 5 latest version by installing which earlier version of Angular CLI?

like image 661
ArifMustafa Avatar asked Dec 18 '22 21:12

ArifMustafa


1 Answers

OS: Ubuntu 18 (Linux)

Note: use sudo as prefix for installing. Windows user open the cmd as administrator.

sudo apt-get update
  1. Installing NodeJS 8.11.3 LTS

    curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
    
    sudo apt-get install -y nodejs
    
    node -v
    v8.11.3
    
  2. npm is installed with Node.js

    npm is distributed with Node.js- which means that when you download Node.js, you automatically get npm installed on your computer.

    npm -v
    6.3.0
    
  3. Get TypeScript

    sudo npm install -g typescript
    
    tsc -v
    Version 3.0.1
    
  4. Use root to install angular/cli

    sudo -s
    root@ubuntu:~# 
    
  5. Use CLI version 1.6.6 for Angular 5.2.11

    root@ubuntu:~# npm install -g @angular/[email protected]
    // it will download files and take some minutes
    
    root@ubuntu:~# ng -v
    
        _                      _                 ____ _     ___
       / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
      / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
     / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
    /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                   |___/
    
    Angular CLI: 1.6.6
    Node: 8.11.3
    OS: linux x64
    Angular: 
    ...
    
  6. Now, exit from root

    exit
    // reach where you want to create your new project
    ng new angular5App
    // it will download files and take some minutes
    
  7. reach inside project directory

    cd angular5App
    // check project dependencies from package.json
    
  8. compile, bundle and run the project

    ng serve -on
    
  9. by default, your project will run on http://localhost:4200/

In Chrome 65 of above version, go to Inspect, Elements,

Inside <body> check <app-root _nghost-c0="" ng-version="5.2.11">

like image 120
ArifMustafa Avatar answered Dec 28 '22 11:12

ArifMustafa