gpt4 book ai didi

angular - 通过哪个 CLI 版本安装 Angular 5

转载 作者:行者123 更新时间:2023-12-02 18:30:46 26 4
gpt4 key购买 nike

我使用的是 Ubuntu 18,想要启动 Angular 5 项目,因此我安装了 Node、npm、TypeScript,最后安装了通过以下命令获取最新稳定的 Angular CLI,

sudo npm install -g @angular/cli

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

之后,我搜索了很多页面,以获得 Angular 5 最新版本 5.2.11 的正确 CLI 版本。

也看了很多帖子,但很多都是去年 2017 年的,当时 Angular 5 刚刚发布。

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

最佳答案

操作系统:Ubuntu 18 (Linux)

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

sudo apt-get update
  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
  2. npm 与 Node.js 一起安装

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

    npm -v
    6.3.0
  3. 获取 TypeScript

    sudo npm install -g typescript

    tsc -v
    Version 3.0.1
  4. 使用 root 安装 angular/cli

    sudo -s
    root@ubuntu:~#
  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:
    ...
  6. 现在,从 root 退出

    exit
    // reach where you want to create your new project
    ng new angular5App
    // it will download files and take some minutes
  7. 进入项目目录

    cd angular5App
    // check project dependencies from package.json
  8. 编译、捆绑并运行项目

    ng serve -on
  9. 默认情况下,您的项目将在 http://localhost:4200/ 上运行

在 Chrome 65 以上版本中,转到“检查”、“元素”,

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

关于angular - 通过哪个 CLI 版本安装 Angular 5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51862813/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com