Search code examples
angularangular-cliangular-cli-v9

Angular error: newTree.optimize is not a function


I recently started getting this error when attempting to create a new component using the angular CLI:

newTree.optimize is not a function

the issued command was:

ng g c test

Googling return only articles from Angular CLI v6.x I have tried uninstalling and reinstalling Angular globally with no luck. Here is my current versioning:

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
Angular CLI: 9.1.0
Node: 12.16.1
OS: win32 x64
Angular:
...
Ivy Workspace:
Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.901.0
@angular-devkit/core         9.1.0
@angular-devkit/schematics   9.1.0
@schematics/angular          9.1.0
@schematics/update           0.901.0
rxjs                         6.5.4

has anyone else found a fix for this?

Thank you!


Solution

  • After I upgraded to angular 9, I had 2 packages that were both still at version 0.6.8, They were:

    @schematics/[email protected]
    @angular-devkit/[email protected]
    

    For whatever reason, they were not upgraded and it resulted in this error.