How do I correctly upgrade angular 2 (npm) to the latest version?

前端 未结 11 1525
予麋鹿
予麋鹿 2020-11-28 00:47

Recently I started Angular 2 tutorial at https://angular.io/docs/ts/latest/tutorial/.

and left off with Angular 2 beta 8. Now I resumed the tutorial and latest beta

11条回答
  •  南笙
    南笙 (楼主)
    2020-11-28 01:42

    If you are looking like me for just updating your project to the latest these is what works form me since Angular 6:

    Open the console on your project folder: If you type: ng update then you will get the below message:

            We analyzed your package.json, there are some packages to update:
    
              Name                               Version                  Command to update
             --------------------------------------------------------------------------------
              @angular/cli                       7.0.7 -> 7.2.2           ng update @angular/cli
              @angular/core                      7.0.4 -> 7.2.1           ng update @angular/core
    
    There might be additional packages that are outdated.
        Run "ng update --all" to try to update all at the same time.
    

    So I usually go straight and do:

    ng update --all

    Finally you can check your new version:

    ng version
    
    Angular CLI: 7.2.2
    Node: 8.12.0
    OS: win32 x64
    Angular: 7.2.1
    ... animations, common, compiler, compiler-cli, core, forms
    ... http, language-service, platform-browser
    ... platform-browser-dynamic, router
    
    Package                           Version
    -----------------------------------------------------------
    @angular-devkit/architect         0.12.2
    @angular-devkit/build-angular     0.12.2
    @angular-devkit/build-optimizer   0.12.2
    @angular-devkit/build-webpack     0.12.2
    @angular-devkit/core              7.2.2
    @angular-devkit/schematics        7.2.2
    @angular/cli                      7.2.2
    @ngtools/webpack                  7.2.2
    @schematics/angular               7.2.2
    @schematics/update                0.12.2
    rxjs                              6.3.3
    typescript                        3.2.4
    webpack                           4.28.4
    

提交回复
热议问题