使用ng update将Angular从7升级到8!

Angular8.0已经发布了吧。

我们已经将Angular7升级到Angular8。
附带执行记录。

环境

Angular CLI: 7.2.4
Node: 10.15.3
OS: win32 x64
Angular: 7.2.15
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.12.4
@angular-devkit/build-angular      0.12.4
@angular-devkit/build-optimizer    0.12.4
@angular-devkit/build-webpack      0.12.4
@angular-devkit/core               7.2.4
@angular-devkit/schematics         7.2.4
@angular/cdk                       7.3.7
@angular/cli                       7.2.4
@angular/flex-layout               7.0.0-beta.24
@angular/material                  7.3.7
@angular/material-moment-adapter   7.3.7
@ngtools/webpack                   7.2.4
@schematics/angular                7.2.4
@schematics/update                 0.12.4
rxjs                               6.3.3
typescript                         3.2.4
webpack                            4.28.4

试试打ng update命令

运行”ng update”命令时,会解析package.json文件并显示可更新的软件包。

    We analyzed your package.json, there are some packages to update:

      Name                               Version                  Command to update
     --------------------------------------------------------------------------------
      @angular/cdk                       7.3.7 -> 8.0.0           ng update @angular/cdk
      @angular/cli                       7.2.4 -> 8.0.1           ng update @angular/cli
      @angular/core                      7.2.15 -> 8.0.0          ng update @angular/core
      @angular/material                  7.3.7 -> 8.0.0           ng update @angular/material
      rxjs                               6.3.3 -> 6.5.2           ng update rxjs


    There might be additional packages that are outdated.
    Run "ng update --all" to try to update all at the same time.

由于写着”ng update –all”,所以我将尝试执行这个命令。

To disable this warning use "ng config -g cli.warnings.versionMismatch false".
                  Package "@angular/compiler-cli" has an incompatible peer dependency to "typescript" (requires ">=3.4 <3.5", would install "3.5.1")
                  Package "@angular-devkit/build-angular" has an incompatible peer dependency to "typescript" (requires ">=3.1 < 3.5", would install "3.5.1")
                  Package "@angular/compiler-cli" has an incompatible peer dependency to "typescript" (requires ">=3.4 <3.5", would install "3.5.1").
Incompatible peer dependencies found. See above.

出现了与 TypeScript 版本相关的警告。按照提示,不要安装 TypeScript 3.5!因为它不受支持,所以不能升级。

因此,放弃批量更新,执行 ng update @angular/cli @angular/core。

    Updating package.json with dependency @angular/language-service @ "8.0.0" (was "7.2.15")...
    Updating package.json with dependency @angular/animations @ "8.0.0" (was "7.2.15")...
    Updating package.json with dependency @angular/common @ "8.0.0" (was "7.2.15")...
    Updating package.json with dependency @angular/compiler-cli @ "8.0.0" (was "7.2.15")...
    Updating package.json with dependency @angular/compiler @ "8.0.0" (was "7.2.15")...
    Updating package.json with dependency @angular/core @ "8.0.0" (was "7.2.15")...
    Updating package.json with dependency @angular/forms @ "8.0.0" (was "7.2.15")...
    Updating package.json with dependency @angular/cli @ "8.0.1" (was "7.2.4")...
    Updating package.json with dependency @angular/platform-browser-dynamic @ "8.0.0" (was "7.2.15")...
    Updating package.json with dependency @angular/platform-browser @ "8.0.0" (was "7.2.15")...
    Updating package.json with dependency @angular/router @ "8.0.0" (was "7.2.15")...
    Updating package.json with dependency zone.js @ "0.9.1" (was "0.8.29")...
    Updating package.json with dependency @angular-devkit/build-angular @ "0.800.1" (was "0.12.4")...
    Updating package.json with dependency rxjs @ "6.5.2" (was "6.3.3")...
    Updating package.json with dependency typescript @ "3.4.5" (was "3.2.4")...
UPDATE package.json (1968 bytes)

> @angular/cli@8.0.1 postinstall C:\Users\user\Documents\develop\project\node_modules\@angular\cli
> node ./bin/postinstall/script.js

? Would you like to share anonymous usage data with the Angular Team at Google under
Google’s Privacy Policy at https://policies.google.com/privacy? For more details and
how to change this setting, see http://angular.io/analytics. (y/N)

如果你不选择要获取统计信息,就无法继续前进。

Thank you for sharing anonymous usage data. If you change your mind, the following
command will disable this feature entirely:

    ng analytics off

npm WARN bootstrap@4.3.1 requires a peer of jquery@1.9.1 - 3 but none is installed. You must install peer dependencies yourself.
npm WARN bootstrap@4.3.1 requires a peer of popper.js@^1.14.7 but none is installed. You must install peer dependencies yourself.
npm WARN codelyzer@4.5.0 requires a peer of @angular/compiler@>=2.3.1 <8.0.0 || >7.0.0-beta <8.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN codelyzer@4.5.0 requires a peer of @angular/core@>=2.3.1 <8.0.0 || >7.0.0-beta <8.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN firebase-functions@2.3.1 requires a peer of firebase-admin@^7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular-devkit/build-angular@0.800.1 requires a peer of typescript@>=3.1 < 3.5 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/compiler-cli@8.0.0 requires a peer of typescript@>=3.4 <3.5 but none is installed. You must install peer dependencies yourself.
npm WARN @ngtools/webpack@8.0.1 requires a peer of typescript@>=3.4 < 3.5 but none is installed. You must install peer dependencies yourself.

added 54 packages from 38 contributors, removed 141 packages, updated 101 packages, moved 17 packages and audited 22379 packages in 193.048s
found 0 vulnerabilities

    ** Executing migrations for package '@angular/cli' **
DELETE src/browserslist
CREATE browserslist (388 bytes)
UPDATE tslint.json (1849 bytes)
UPDATE package.json (1969 bytes)
UPDATE src/polyfills.ts (2838 bytes)
UPDATE tsconfig.json (538 bytes)
UPDATE src/tsconfig.app.json (166 bytes)
UPDATE src/tsconfig.spec.json (256 bytes)
UPDATE src/app/app-routing.module.ts (907 bytes)
npm WARN @angular-devkit/build-angular@0.800.1 requires a peer of typescript@>=3.1 < 3.5 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/compiler-cli@8.0.0 requires a peer of typescript@>=3.4 <3.5 but none is installed. You must install peer dependencies yourself.
npm WARN @ngtools/webpack@8.0.1 requires a peer of typescript@>=3.4 < 3.5 but none is installed. You must install peer dependencies yourself.
npm WARN bootstrap@4.3.1 requires a peer of jquery@1.9.1 - 3 but none is installed. You must install peer dependencies yourself.
npm WARN bootstrap@4.3.1 requires a peer of popper.js@^1.14.7 but none is installed. You must install peer dependencies yourself.
npm WARN firebase-functions@2.3.1 requires a peer of firebase-admin@^7.0.0 but none is installed. You must install peer dependencies yourself.

added 4 packages from 7 contributors, updated 1 package and audited 22385 packages in 7.953s
found 0 vulnerabilities

    ** Executing migrations for package '@angular/core' **
            ------ Static Query Migration ------
            With Angular version 8, developers need to
            explicitly specify the timing of ViewChild and
            ContentChild queries. Read more about this here:
            https://v8.angular.io/guide/static-query-migration
            ------------------------------------------------

更新完成!辛苦了。

以下是参考答案:

Angular更新指南
包”@angular/compiler-cli”与”typescript”存在不兼容的依赖关系(需要”>=3.1.1 <3.3″,但会安装”3.4.5″)。 ·问题# 14561 · angular / angular-cli

广告
将在 10 秒后关闭
bannerAds