代码之家  ›  专栏  ›  技术社区  ›  ArifMustafa

安装Angular 5,通过它安装CLI版本

  •  1
  • ArifMustafa  · 技术社区  · 6 年前

    我正在使用Ubuntu18,想启动Angular5项目,因此我安装了Node、npm、TypeScript,最后 最新的稳定角度命令如下,

    sudo npm install -g @angular/cli
    

    而不是角度5,这是我的要求。

    也看了很多帖子,但很多都是从去年2017年开始的,那时Angular5刚刚出版。

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

    1 回复  |  直到 6 年前
        1
  •  7
  •   Heretic Monkey goproxy.dev    6 年前

    操作系统:Ubuntu18(Linux)

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

    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一起发布,这意味着当您下载Node.js时,您会自动在您的计算机上安装npm。

      npm -v
      6.3.0
      
    3. 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. 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中,转到Inspect,Elements,

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

        2
  •  0
  •   Krishna Jangid    5 年前

    就这么做

    1. 创建新文件夹说“ angularprojects
    2. 转到“ 安格拉项目
    3. 现在运行这个命令: sudo npm install -g @angular/cli@1.6.6
    4. 现在使用 sudo ng new my-first-project 或粘贴存在项目

    5. 现在键入 cd my-first-project

    6. ng serve