angular-cli: Cannot read property 'entries' of undefined

[x ] bug report I am submitting this as a bug because there is no clear and definitive answer on how to troubleshoot this issue. It seems to be effecting developers in different ways and / or for different reasons.

Command

- [ x] generate

Versions

npm --version 5.6.0 macOS --version High Sierra Angular CLI: 6.1.4 Node: 8.11.4 OS: darwin x64 Angular: 6.1.3 … animations, common, compiler, compiler-cli, core, forms … http, language-service, platform-browser … platform-browser-dynamic, router, service-worker

Package Version

@angular-devkit/architect 0.6.8 @angular-devkit/build-angular 0.6.8 @angular-devkit/build-optimizer 0.6.8 @angular-devkit/core 0.6.8 @angular-devkit/schematics 0.6.8 @angular/cli 6.1.4 @angular/pwa 0.6.8 @ngtools/webpack 6.0.8 @schematics/angular 0.6.8 @schematics/update 0.7.4 rxjs 6.2.2 typescript 2.9.2 webpack 4.8.3

Repro steps

ng generate command fails for all types component, module, etc, with the following dreaded error:

Cannot read property 'entries' of undefined

with the debug flag, i am seeing this: at new FilteredTree (/Users/mike/myapp/node_modules/@angular-devkit/schematics/src/tree/filtered.js:13:18)

Maybe it is worth digging into @angular-devkit to figure this out myself. 😕

Mention any other details that might be useful

I have already tried removing the node_modules directory and re-installing.

Also tried removing node, npm and angular-cli all together followed by clean installs of each.

In my particular case…

Important to note, that ng serve and ng build are functioning correctly despite the problem with generate.

Also, generating a new project works, as well as using generate within the new project directory OK, so where do i begin to troubleshoot this issue in my existing project?

ANY help greatly appreciated.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 5
  • Comments: 15

Most upvoted comments

@gitdisrupt , I had the same issue, I tried to update @angular/pwa package to version ~0.7.5, and this resolved the problem for me.

I think this might be a duplicate of the issue #11885.

I solved my specific case.

Thanks to @hvedir. His results noted above sent me in the right direction.

The issue was due to an incompatibility in my angular.json file as well.

My project was originally generated using an older version of the Angular CLI. Offhand i could not tell you the exact version number, but i can tell you it was sometime after the release of Angular v4.

The key takeaway being that i had originally generated my project with the --skip-tests flag which set the "schematics" accordingly in the original angular-cli.json file in a format not compatible with Angular v6.

The --skip-tests flag when used along with ng new at that time had set my schematics as follows:

"schematics": {
        "@schematics/angular:component": {
          "styleext": "scss",
          "spec": false
        },
        "@schematics/angular:class": {
          "spec": false
        },
        "@schematics/angular:directive": {
          "spec": false
        },
        "@schematics/angular:guard": {
          "spec": false
        },
        "@schematics/angular:module": {
          "spec": false
        },
        "@schematics/angular:pipe": {
          "spec": false
        },
        "@schematics/angular:service": {
          "spec": false
        }
      }

I had since upgraded my project to Angular 6 manually, using the guide provided, but there was no mention that these settings in particular would need adjustment.

Removing those schematics solved my problem. I just set it to the default: "schematics": {}

And with that I am now again able to generate all types, service, component, module etc, albeit if i do not want spec files generated moving forward, i need to use the --no-spec flag along with the generate command each time. That is until i can find out how to correctly configure the schematics for Angular v6.

Its possible the correct configuration would need to follow the conventions outlined here, but i have not taken the time to test this just yet: https://github.com/angular/angular-cli/blob/v6.0.0-rc.8/packages/%40angular/cli/lib/config/schema.json#L71

As mentioned in my comment above, this error seems to fire in varying ways, so i suspect that if anyone else is seeing this error for another reason, digging through your angular.json file is likely a good place to start troubleshooting.

Upgraded @schematics/angular to the angular version installed solved to me the problem.

I had the same problem and updating @angular/pwa to the latest worked for me

I had the same issue. In my case, it was outdated angular.json. Try to rename “targets” keys in angular.json to “architect”. Before:

      "schematics": {
      },
      "targets": {
        "build": {
       ....

After:

      "schematics": {
      },
      "architect": {
        "build": {
      ....

Hi @martinbdz i created this issue because that issue you are referring to is different. This problem seems to be effecting people in different ways. His issue is different from mine.

What id like to see here is a clear set of instructions on how to begin troubleshooting this error.

Creating a new project and slowly migrating all of my app src over seems like a nightmare of a task that in theory should be avoidable.