angular-cli: Error "Tree type is not supported." when generating new module in v6.1.1

Bug Report or Feature Request (mark with an x)

- [ X ] bug report -> please search issues before submitting
- [ ] feature request

Command (mark with an x)

- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ X ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Versions

Angular CLI 6.1.1 Windows 10 Node 10.7.0 Yarn 1.9.2

Repro steps

Upgrade to the latest version of Angular 6.1.1 (Works okay on 6.1.0) run ng g module modules/test2 --flat or just ng g module modules/test2 or just ng g module test2 or just ng g m test2

Interestingly, it works when generating modules with routing flag, but haven’t had any success with any other flags

ng g module modules/test2 --flat -routing or ng g module test2 --routing works.

The log given by the failure

I am getting a simple message without any other details attached:

Tree type is not supported.

Not enough information to help me troubleshoot where the problem is. I tried this on two of my projects.

Desired functionality

Should generate a new module in the specified location.

UPDATE

I also deleted the entire node_modules folder and re installed the packages without success. Downgrading back to 6.1.0 works as expected.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 5
  • Comments: 39 (3 by maintainers)

Commits related to this issue

Most upvoted comments

Updating my custom schematic to:

"@angular-devkit/architect": "0.7.2",
"@angular-devkit/core": "0.7.2",
"@angular-devkit/schematics": "0.7.2",

And Angular CLI:

"@angular-devkit/build-angular": "0.7.2",
"@angular/cli": "~6.1.2",

Still gives the error:

Tree type is not supported.

Am I missing something else?

I ran yarn install and yarn upgrade and then it worked.

Clean install of latest Angular CLI this morning. v6.1.1

I also get this message when running:

ng new --style=scss --routing --skip-tests --skip-git example

I also tried 6.1.0 same error. I had to downgrade CLI version to 6.0.7 in order for ng new to work.

As @StephenFluin note in another post. I reinstall @angular/cli from global and project itself. It solved the issue.

Got similar issues

> ng g c compName
Tree type is not supported.

Here’s the schematic versions

> npm ls @angular-devkit/schematics
`-- @angular/cli@6.1.1
  +-- @angular-devkit/schematics@0.7.1
  +-- @schematics/angular@0.7.1
  | `-- @angular-devkit/schematics@0.7.1
  `-- @schematics/update@0.7.1
    `-- @angular-devkit/schematics@0.7.1
> ng --version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 6.1.1
Node: 9.10.1
OS: win32 x64
Angular: 6.1.0
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.7.1
@angular-devkit/build-angular     0.7.1
@angular-devkit/build-optimizer   0.7.1
@angular-devkit/build-webpack     0.7.1
@angular-devkit/core              0.7.1
@angular-devkit/schematics        0.7.1
@angular/cdk                      6.4.2
@angular/cli                      6.1.1
@angular/flex-layout              6.0.0-beta.17
@angular/material                 6.4.2
@ngtools/webpack                  6.1.1
@schematics/angular               0.7.1
@schematics/update                0.7.1
rxjs                              6.2.2
typescript                        2.9.2
webpack                           4.9.2

Tree.optimize() is not a function was fixed in https://github.com/angular/angular-cli/pull/11693 (which isn’t released yet but will be in 6.1.2 this Wednesday).

I’m keeping this issue open as we need to figure out forward compatibility in Schematics for people who have multiple version of a library.

@nisimjoseph thx - that helped. I am using angular/cli 6.1.4. Solution: 1 ) delete node-modules folder and 2) package-lock file 3) then run npm install.

try to remove the entire node_module folder + delete package_lock file.

After investigating I found that in the following code:

function filter(predicate) {
    return ((tree) => {
        // TODO: Remove VirtualTree usage in 7.0
        if (tree instanceof virtual_1.VirtualTree) {
            return new filtered_1.FilteredTree(tree, predicate);
        }
        else if (tree instanceof host_tree_1.HostTree) {
            return new host_tree_1.FilterHostTree(tree, predicate);
        }
        else {
            throw new exception_1.SchematicsException('Tree type is not supported.');
        }
    });
}

tree instanceof host_tree_1.HostTree returns false in my custom schematics.

@odahcam Thanks. I can confirm that works. I first removed the node_modules directory, then ran yarn install and then ran yarn upgrade.

Upgrade from 6.0.7 to 6.1.0 has the same issue with ‘generate’ command. Output:

ng g service ExampleService
newTree.optimize is not a function