【问题标题】:angular can't update because of typescript dependencies由于打字稿依赖性,角度无法更新
【发布时间】:2020-03-16 13:18:06
【问题描述】:

这是我的离子信息:

Ionic CLI                     : 6.2.1 (C:\Users\Arashsoft\AppData\Roaming\npm\node_modules\@ionic\cli)
Ionic Framework               : @ionic/angular 5.0.5
@angular-devkit/build-angular : 0.803.25
@angular-devkit/schematics    : 8.3.25
@angular/cli                  : 9.0.6

我想更新@angular-devkit/build-angular,但出现以下错误:

  1. 首先,我在运行ng update @angular/core 后遇到这些错误:

    Repository is not clean. Please commit or stash any changes before updating.  
    
  2. 然后我再次尝试使用此命令:

    ng update @angular/cli @angular/core --allow-dirty
    

    然后得到这些错误:

    Package "@angular-devkit/build-angular" has an incompatible peer dependency to "typescript" (requires ">=3.1 < 3.6", would install "3.7.5").      
    × Migration failed: Incompatible peer dependencies found.
    Peer dependency warnings when installing dependencies means that those dependencies might not work correctly together.
    You can use the '--force' option to ignore incompatible peer dependencies and instead address these warnings later.
      See "C:\Users\ARASHS~1\AppData\Local\Temp\ng-zWLLPl\angular-errors.log" for further details.
    

我该如何解决?

【问题讨论】:

    标签: node.js angular npm command-line-interface


    【解决方案1】:

    Ionic doesn't seem to support Angular 9 yet,最好等到官方支持到来。

    如果您仍然想尝试它,Angular 有a dedicated upgrade page,您可以在其中按照程序进行操作。简而言之:

    • 您将@angular/cli@angular/core 更新到最新的8.x.x 版本
    • 您将@angular/cli@angular/core 更新到最新的9.x.x 版本,暂时可能需要忽略--force 的对等依赖问题
    • 之后,您可以通过ng update 更新其他与 Angular 相关的依赖项
    • 一旦您的所有依赖项都是最新的,错误消息就会消失

    至于1),你的 git repo 需要干净,因为 Angular 不想弄乱你的本地更改,你可能已经更改了一些文件,你可以使用 git 客户端(如 Sourcetree 或只需使用命令行git status 即可打印出哪些文件已更改。

    关于2),我不建议使用--allow-dirty,总是尝试获得一个干净的git状态,然后进行升级。

    如果你是 git 新手,我强烈推荐 reading up on the docs

    希望对您有所帮助,祝您编码愉快!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-05
      • 2018-11-04
      • 2013-08-16
      • 1970-01-01
      • 1970-01-01
      • 2020-09-06
      相关资源
      最近更新 更多