由于打字稿的依赖性,角度无法更新

时间:2020-03-16 13:18:06

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

这是我的离子信息:

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.
    

我该如何解决?

1 个答案:

答案 0 :(得分:0)

离子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客户端(如{{ 3}}或仅通过使用命令行git status即可打印已更改的文件。

关于2),我不建议使用--allow-dirty,请始终尝试获取干净的git状态,然后进行升级。

如果您是git的新手,我强烈建议Sourcetree

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

相关问题