通过哪个CLI版本安装Angular 5

Ari*_*afa 3 npm-install angular-cli angular angular5

我正在使用Ubuntu 18,并希望启动Angular 5项目,因此我通过以下命令安装了Node,npm,TypeScript,最后安装了最新的稳定Angular CLI,

sudo npm install -g @angular/cli
Run Code Online (Sandbox Code Playgroud)

因此,默认情况下,它正在下载最新的稳定的Angular CLI,现在是6.1.3,默认情况下,它是Angular 6版本而不是Angular 5的版本,这是我的要求。

之后,我在同一页面上搜索了许多页面,以获取正确的CLI版本,以获得适用于Angular 5的最新版本5.2.11。

还看了很多帖子,但很多是从2017年Angular 5新发布的去年开始的。

所以我的问题是通过安装哪个较早版本的Angular CLI获取Angular 5最新版本?

Ari*_*afa 7

操作系统:Ubuntu 18(Linux)

注意:sudo用作安装前缀。Windows用户以管理员身份打开cmd。

sudo apt-get update
Run Code Online (Sandbox Code Playgroud)
  1. 安装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
    
    Run Code Online (Sandbox Code Playgroud)
  2. npm与Node.js一起安装

    npm与Node.js一起分发,这意味着当您下载Node.js时,会自动在计算机上安装npm。

    npm -v
    6.3.0
    
    Run Code Online (Sandbox Code Playgroud)
  3. 获取TypeScript

    sudo npm install -g typescript
    
    tsc -v
    Version 3.0.1
    
    Run Code Online (Sandbox Code Playgroud)
  4. 使用root安装angular / cli

    sudo -s
    root@ubuntu:~# 
    
    Run Code Online (Sandbox Code Playgroud)
  5. 对Angular 5.2.11使用CLI版本1.6.6

    root@ubuntu:~# npm install -g @angular/cli@1.6.6
    // 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: 
    ...
    
    Run Code Online (Sandbox Code Playgroud)
  6. 现在,从根目录退出

    exit
    // reach where you want to create your new project
    ng new angular5App
    // it will download files and take some minutes
    
    Run Code Online (Sandbox Code Playgroud)
  7. 到达项目目录内

    cd angular5App
    // check project dependencies from package.json
    
    Run Code Online (Sandbox Code Playgroud)
  8. 编译,捆绑并运行项目

    ng serve -on
    
    Run Code Online (Sandbox Code Playgroud)
  9. 默认情况下,您的项目将在 http://localhost:4200/

在以上版本的Chrome 65中,转到检查,元素,

内部<body>检查<app-root _nghost-c0="" ng-version="5.2.11">