ng update to specific Angular version

前端 未结 5 1089
感情败类
感情败类 2020-12-18 18:13

I would like to update Angular from version 5.0 to version 6.1. The instructions at https://update.angular.io/ suggest using ng update @angular/core to update.

5条回答
  •  旧时难觅i
    2020-12-18 18:57

    If you are upgrading to an older version, as recommended by Angular to upgrade to the next major version first instead of moving directly to the latest version (like current latest version is v10 and you are upgrading from v8, its recommended to first upgrade to v9 and then to v10), then you have to provide the update the dependencies/package to the latest version compatible with Angular9.

    For upgrading, first check the required dependencies to be updated with the help of

    ng update - which will list all the dependencies you have to update(see image)

    Referring to the picture, there are 6 packages to update which we will update to the version we are upgrading to(in this case it is v9) using ng update command:

    ng update @angular/cdk@9 @angular/cli@9 @angular/core@9 @angular/material@9 @ngx-pwa/local-storage@9 rxjs --force
    

    (you can define specific versions of the packages by going to npm packages, for example - @angular/core@9.1.2 as 9.1.2 is the latest stable release of @angular/core package for angular9).

    This will update your project to angular v9.

    Similarly, for v10, you need to follow the above process.

    [Note: For the latest angular version(which is v10 at the time of writing this), you need not provide the version during update and you can directly update as:

    ng update @angular/cdk @angular/cli --force

    You can also use npm outdated to view the outdated packages which needs to be updated.

    Hope this answer proves helpful for you. If you find any issues, please comment and I'll try to provide solution.

提交回复
热议问题