angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Error "Tree type is not supported." when generating new module in v6.1.1

Open mainawycliffe opened this issue 8 years ago • 39 comments

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.

mainawycliffe avatar Jul 27 '18 03:07 mainawycliffe

nope, global reinstall did not help. I guess I want routing!

toddwseattle avatar Aug 04 '18 03:08 toddwseattle

@toddwseattle try updating your packages using npm (npm update). That's how i solved the issue, although am using yarn but I am guessing it should work for npm too.

mainawycliffe avatar Aug 04 '18 04:08 mainawycliffe

@mainawycliffe npm update did not solve...moved on with the --routing work around

toddwseattle avatar Aug 04 '18 15:08 toddwseattle

There is something wrong with the filter function, when I removed it, it works fine.

    const templateSource = apply(url('./files'), [
      options.spec ? noop() : filter(path => !path.endsWith('.spec.ts')),
      template({
        ...stringUtils,
        ...options
      }),
      move(parsedPath.path)
    ]);

This works:

    const templateSource = apply(url('./files'), [
      template({
        ...stringUtils,
        ...options
      }),
      move(parsedPath.path)
    ]);

ArielGueta avatar Aug 04 '18 19:08 ArielGueta

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.

ArielGueta avatar Aug 04 '18 20:08 ArielGueta

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

nisimjoseph avatar Aug 06 '18 19:08 nisimjoseph

I get the same problem with @angular/[email protected] impossible to get rid of this error. I tried both npm update and delete/reinstall both my project's node_modules and the global angular/cli installation without success.

Alekshar avatar Aug 07 '18 13:08 Alekshar

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

nisimjoseph avatar Aug 07 '18 14:08 nisimjoseph

Thank you @nisimjoseph . That saved me some pain.

isaacplmann avatar Aug 07 '18 15:08 isaacplmann

Same issue Tree type is not supporteed but generating ngrx action. any workaround for this?

webcat12345 avatar Aug 09 '18 02:08 webcat12345

Same again here, my command line: ng generate action Bookings --group

Any suggestions? I'm assuming there's some issue with the following file: \node_modules@ngrx\schematics\src\action\index.ts

inthegarage avatar Aug 10 '18 12:08 inthegarage

@inthegarage please refer this issue I was able to solve the issue.

webcat12345 avatar Aug 11 '18 02:08 webcat12345

I'm having the same issue. Bumped into it when writing my own schematic. My tests work fine, but when I run the actual schematic using the schematics-cli I got the error. Turns out the angular-cli also gives the error, so it must be something in @schematics/angular?

Angular CLI: 6.1.3
Node: 8.11.3
OS: win32 x64
Angular: undefined
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.7.3 (cli-only)
@angular-devkit/core         0.7.3
@angular-devkit/schematics   0.7.3
@schematics/angular          0.7.3
@schematics/update           0.7.3 (cli-only)
rxjs                         6.2.2
typescript                   2.9.2

JoepKockelkorn avatar Aug 12 '18 16:08 JoepKockelkorn

I'm also experiencing this issue.

Seems to have something to do with this commit: https://github.com/angular/angular-cli/commit/9582b84603182d43dbb9f0e6a8db600e83921f8a

frankvdb7 avatar Aug 17 '18 12:08 frankvdb7

@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.

JackRus avatar Aug 20 '18 16:08 JackRus

Why is this issue closed? This is still a problem in this version. Uninstalling and reinstalling cli does not work. It is also not fixed with downgrading.

will0684 avatar Aug 20 '18 17:08 will0684

@will0684 I just posted above your comment. Please try it.

JackRus avatar Aug 20 '18 17:08 JackRus

The issue is closed automatically when the PR is merged that fixes it. You can get the fixed version from our snapshot build now https://github.com/angular/cli-builds or wait for a release that includes the fix if you want to verify it from an npm install.

alexeagle avatar Aug 20 '18 18:08 alexeagle

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.