らいふうっどの閑話休題

興味のあることをゆる~く書いていく

ng update で、Migration failed: this.tree.readText is not a function が出た時の対応

ng update で、Migration failed: this.tree.readText is not a function が出た時の対応

ng update したら失敗
➜  portfolio git:(feature/next) ng update @angular/cli@v14.0.0-next.13 --force
The installed Angular CLI version is outdated.
Installing a temporary Angular CLI versioned 13.3.5 to perform the update.
✔ Packages successfully installed.
Using package manager: 'npm'
Collecting installed dependencies...
Found 49 dependencies.
Fetching dependency metadata from registry...
    Updating package.json with dependency @angular-devkit/architect @ "0.1400.0-next.13" (was "0.1400.0-next.12")...
    Updating package.json with dependency @angular-devkit/build-angular @ "14.0.0-next.13" (was "14.0.0-next.12")...
    Updating package.json with dependency @angular/cli @ "14.0.0-next.13" (was "14.0.0-next.12")...
  UPDATE package.json (2701 bytes)
✔ Packages successfully installed.
** Executing migrations of package '@angular/cli' **

❯ Remove 'defaultProject' option from workspace configuration.
  The project to use will be determined from the current working directory.
✖ Migration failed: this.tree.readText is not a function
  See "/private/var/folders/fb/ww70j2nn1nv5l6x_663nnlfh0000gn/T/ng-tvwxQB/angular-errors.log" for further details.
対応
  • --next を使えば良い
➜  portfolio git:(feature/next) ng update --next
Using package manager: npm
Collecting installed dependencies...
Found 49 dependencies.
    We analyzed your package.json, there are some packages to update:

      Name                               Version                  Command to update
     --------------------------------------------------------------------------------
      @angular/cdk                       14.0.0-next.12 -> 14.0.0-next.13 ng update @angular/cdk --next
      @angular/core                      14.0.0-next.15 -> 14.0.0-next.16 ng update @angular/core --next
      @angular/material                  14.0.0-next.12 -> 14.0.0-next.13 ng update @angular/material --next

    There might be additional packages which don't provide 'ng update' capabilities that are outdated.
    You can update the additional packages by running the update command of your package manager.
➜  portfolio git:(feature/next) ng update @angular/cli @angular/core @angular/cdk @angular/material --next --force
発見
  • ng update --next で、更新対象モジュールを表示出来る事を今頃知った
  • いちいちバージョン指定しなくても --next を使えば良いことを今頃知った
  • --force は適度に使うべし
参考

angular.jp

github.com

github.com