angular/cli 常用指令

时间:2023-03-08 17:57:41

  1.安装@angular/cli

    npm install -g @angular/cli

  2.更新@angular/cli  

    npm uninstall -g @angular/cli

    npm cache clean

    npm install -g @angular/cli

  3.新建项目

    ng new <project-name> [options]

  4.在项目中构建新代码

    ng g [Component|Directive|Pipe|Service|Class|Interface|Enum|Module] <generate-name>

  5.生成项目

    ng build

  6.在项目中运用karma进行单元测试

    ng test

  7.初始化一个新angular项目(当前路径下)

    ng init

  8.格式化当前项目(clang-format)

    ng format

  9.获取@angular/cli版本

    ng version