Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mainawycliffe opened this issue Jul 27, 2018 · 39 comments
Closed

Comments

@mainawycliffe
Copy link

mainawycliffe commented Jul 27, 2018

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.

@darrenmothersele
Copy link

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.

@mainawycliffe
Copy link
Author

@darrenmothersele That's interesting, because I tried to run the above command on my v6.1.1 and it was successfully executed. I also went ahead and created a new project and run the commands that could not executed earlier successfully without any issues. On my part, it seems to be an issue with upgrading to Angular 6.1.1 from 6.1.0.

@akshaysinghrana
Copy link

Versions
Angular CLI: 6.1.1
Node: 8.11.3
OS: linux x64
I got the same problem and unable to downgrade the version of angular/cli. Removed node, npm and angular and again install them with the angular version 6.1.0. But it still shows the above versions.
The issue is not resolved. Can anyone help me to find the root cause of the issue.

@hansl
Copy link
Contributor

hansl commented Jul 27, 2018

Hi,

Could you run npm ls @angular-devkit/schematics on your command line and paste the output here?

Also, as a way to try to fix this, could you try getting rid of you node_modules folder and reinstalling your project packages?

@mainawycliffe
Copy link
Author

Here is the output of the npm ls @angular-devkit/schematics

hades@0.0.0 C:\Users\maina\Projects\hades
+-- @angular/cli@6.1.1
| +-- @angular-devkit/schematics@0.7.1
| +-- @schematics/angular@0.7.1
| | `-- @angular-devkit/schematics@0.7.1  deduped
| `-- @schematics/update@0.7.1
|   `-- @angular-devkit/schematics@0.7.1  deduped
`-- @angular/pwa@0.7.0
  +-- @angular-devkit/schematics@0.7.0
  `-- @schematics/angular@0.7.0
    `-- @angular-devkit/schematics@0.7.0

I already tried to remove the entire node_modules folder and reinstalling the packages without success.

@adnanebrahimi
Copy link

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

@mainawycliffe
Copy link
Author

@adnanebrahimi Am also getting the same error on both 6.1.0 and 6.1.1.

newTree.optimize is not a function

@ArielGueta
Copy link

Any news on this? I was getting newTree.optimize is not a function, then, after updating my custom schematics to 0.7, I'm getting Tree type is not supported.

@odahcam
Copy link

odahcam commented Jul 30, 2018

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

@mainawycliffe
Copy link
Author

mainawycliffe commented Jul 30, 2018

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

@mainawycliffe
Copy link
Author

It seems like ng update is not updating some schematics packages. Some were still stack at 0.7.0 but after yarn upgrade, all are updated to 0.7.1

Before:

+-- @angular/cli@6.1.1
| +-- @angular-devkit/schematics@0.7.1
| +-- @schematics/angular@0.7.1
| | `-- @angular-devkit/schematics@0.7.1  deduped
| `-- @schematics/update@0.7.1
|   `-- @angular-devkit/schematics@0.7.1  deduped
`-- @angular/pwa@0.7.0
  +-- @angular-devkit/schematics@0.7.0
  `-- @schematics/angular@0.7.0
    `-- @angular-devkit/schematics@0.7.0

After:

+-- @angular/cli@6.1.1
| +-- @angular-devkit/schematics@0.7.1
| +-- @schematics/angular@0.7.1
| | `-- @angular-devkit/schematics@0.7.1  deduped
| `-- @schematics/update@0.7.1
|   `-- @angular-devkit/schematics@0.7.1  deduped
`-- @angular/pwa@0.7.1
  `-- @angular-devkit/schematics@0.7.1  deduped

@NetanelBasal
Copy link

+1

@hansl
Copy link
Contributor

hansl commented Jul 30, 2018

Tree.optimize() is not a function was fixed in #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.

@ArielGueta
Copy link

6.1.2 will also support backward compatibility?

@snebjorn
Copy link

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

@ArielGueta
Copy link

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?

@mainawycliffe
Copy link
Author

Here too, the problem still exists. I have to run yarn upgrade after upgrading to 6.2.2 for everything to work as expected.

@ArielGueta
Copy link

Something new about this? I can't publish a new release of my custom schematics.

@adnanebrahimi
Copy link

I solved this issue by updating all cli packages individually that listed in readme

@toddwseattle
Copy link

Having this same problem. ng g module shared -d returns Tree Type Not Supported error.

npm ls @angular-devkit/schematics returns:

+-- @angular/cli@6.1.2
| +-- @angular-devkit/schematics@0.7.2
| +-- @schematics/angular@0.7.2
| | `-- @angular-devkit/schematics@0.7.2  deduped
| `-- @schematics/update@0.7.2
|   `-- @angular-devkit/schematics@0.7.2
`-- @angular/pwa@0.7.2
  +-- @angular-devkit/schematics@0.7.2
  `-- @schematics/angular@0.7.2
    `-- @angular-devkit/schematics@0.7.2  deduped

and ng -v returns:

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

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.7.2
@angular-devkit/build-angular     0.7.2
@angular-devkit/build-optimizer   0.7.2
@angular-devkit/build-webpack     0.7.2
@angular-devkit/core              0.7.2
@angular-devkit/schematics        0.7.2
@angular/cdk                      6.4.2
@angular/cli                      6.1.2
@angular/material                 6.4.2
@angular/pwa                      0.7.2
@ngtools/webpack                  6.1.2
@schematics/angular               0.7.2
@schematics/update                0.7.2
rxjs                              6.2.2
typescript                        2.7.2
webpack                           4.9.2

like @mainawycliffe said in the first report, seems to work if you do --module flag.

will try re-installing cli globally as @StephenFluin did to see if it helps.

I'm using npm not yarn.

@toddwseattle
Copy link

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

@mainawycliffe
Copy link
Author

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

@toddwseattle
Copy link

toddwseattle commented Aug 4, 2018

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

@ArielGueta
Copy link

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
Copy link

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.

@nisimjoseph
Copy link

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

@Alekshar
Copy link

Alekshar commented Aug 7, 2018

I get the same problem with @angular/cli@6.1.2
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.

@nisimjoseph
Copy link

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

@isaacplmann
Copy link

Thank you @nisimjoseph . That saved me some pain.

@webcat12345
Copy link

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

@inthegarage
Copy link

inthegarage commented Aug 10, 2018

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

@webcat12345
Copy link

webcat12345 commented Aug 11, 2018

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

@JoepKockelkorn
Copy link

JoepKockelkorn commented Aug 12, 2018

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

@frankvdb7
Copy link

I'm also experiencing this issue.

Seems to have something to do with this commit: 9582b84

@JackRus
Copy link

JackRus commented Aug 20, 2018

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

@will0684
Copy link

will0684 commented Aug 20, 2018

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.

@JackRus
Copy link

JackRus commented Aug 20, 2018

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

@alexeagle
Copy link
Contributor

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.

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests