Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 796
Kevin192291 Avatar asked Mar 03 '23 14:03

Kevin192291


2 Answers

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.

like image 144
Kevin192291 Avatar answered Mar 08 '23 23:03

Kevin192291


The answer above was correct for me but I thought I'd expand on it, in case anyone else runs into the same issue...

@schematics/angular
@angular-devkit/schematics
@angular-devkit/core

were all on 0.6.8. Running the following resolved my issue:

npm install @schematics/angular
npm install @angular-devkit/schematics
npm install @angular-devkit/core

I hope this helps :)

like image 33
Janey Avatar answered Mar 09 '23 00:03

Janey