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.
nope, global reinstall did not help. I guess I want routing!
@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 npm update did not solve...moved on with the --routing work around
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)
]);
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.
As @StephenFluin note in another post. I reinstall @angular/cli from global and project itself. It solved the issue.
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.
try to remove the entire node_module folder + delete package_lock file.
Thank you @nisimjoseph . That saved me some pain.
Same issue Tree type is not supporteed but generating ngrx action. any workaround for this?
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 please refer this issue I was able to solve the issue.
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
I'm also experiencing this issue.
Seems to have something to do with this commit: https://github.com/angular/angular-cli/commit/9582b84603182d43dbb9f0e6a8db600e83921f8a
@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.
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 I just posted above your comment. Please try it.
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.
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.