Cannot read property 'entries' of undefined in Angular 6

1.3k views Asked by At

before anyone marks this as duplicate, I have tried all the solutions posted, and I have been to GitHub issues and here in StackOverflow, none of the solutions have worked for me.

Whenever I try to generate anything in angular it gives me this error. This started when I installed @angular/pwa though am not sure if this entirely is the cause because I haven't tried the generate command in any of my earlier apps for a while. I uninstalled nodejs entirely and reinstalled it again, deleted all node_modules both global ones and local ones, all this bore no fruit, kindly assist because am left with duplicating components and editing them which although isn't much but it feels like a task on its own. thanks in advance.

EDIT

This is the errror am getting when i append the --debug flag

An error occured:
Cannot read property 'entries' of undefined
TypeError: Cannot read property 'entries' of undefined
    at new FilteredTree (/media/hamisi/New Volume/Work Projects/diaspora-selfcare-portal/frontend/node_modules/@angular-devkit/schematics/src/tree/filtered.js:13:18)
    at /media/hamisi/New Volume/Work Projects/diaspora-selfcare-portal/frontend/node_modules/@angular-devkit/schematics/src/rules/base.js:82:22
    at MergeMapSubscriber.input.pipe.operators_1.mergeMap.inputTree [as project] (/media/hamisi/New Volume/Work Projects/diaspora-selfcare-portal/frontend/node_modules/@angular-devkit/schematics/src/rules/call.js:77:24)
    at MergeMapSubscriber._tryNext (/media/hamisi/New Volume/Work Projects/diaspora-selfcare-portal/frontend/node_modules/rxjs/internal/operators/mergeMap.js:69:27)
    at MergeMapSubscriber._next (/media/hamisi/New Volume/Work Projects/diaspora-selfcare-portal/frontend/node_modules/rxjs/internal/operators/mergeMap.js:59:18)
    at MergeMapSubscriber.Subscriber.next (/media/hamisi/New Volume/Work Projects/diaspora-selfcare-portal/frontend/node_modules/rxjs/internal/Subscriber.js:68:18)
    at Observable._subscribe (/media/hamisi/New Volume/Work Projects/diaspora-selfcare-portal/frontend/node_modules/rxjs/internal/observable/scalar.js:6:20)
    at Observable._trySubscribe (/media/hamisi/New Volume/Work Projects/diaspora-selfcare-portal/frontend/node_modules/rxjs/internal/Observable.js:43:25)
    at Observable.subscribe (/media/hamisi/New Volume/Work Projects/diaspora-selfcare-portal/frontend/node_modules/rxjs/internal/Observable.js:29:22)
    at MergeMapOperator.call (/media/hamisi/New Volume/Work Projects/diaspora-selfcare-portal/frontend/node_modules/rxjs/internal/operators/mergeMap.js:39:23)

And this is what am getting when i run ng -v

Angular CLI: 6.2.1
Node: 10.10.0
OS: linux x64
Angular: 6.1.7
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router, service-worker

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.7.5
@angular-devkit/build-angular     0.7.5
@angular-devkit/build-optimizer   0.7.5
@angular-devkit/build-webpack     0.7.5
@angular-devkit/core              0.7.5
@angular-devkit/schematics        0.6.8
@angular/cli                      6.2.1
@angular/pwa                      0.6.8
@ngtools/webpack                  6.1.5
@schematics/angular               0.6.8
@schematics/update                0.8.1
rxjs                              6.3.2
typescript                        2.7.2
webpack                           4.9.2
2

There are 2 answers

0
Sajeetharan On

You can fix this by two ways,

(i) reinstall NodeJS.Delete node_modules folder from user directory and hit npm install

(ii) Try to update @angular/pwa package to version ~0.7.5 as mentione here

0
sagarsys On

I had a similar issue while trying to use the schematics to generate something. I tried explicitly installing @schematics/angular and setting my default cli collection using:

npm i @schematics/angular --save-dev
ng config cli.defaultCollection @schematics/angular

It did not work for me.

So instead, since I'm already using ngrx in my project, I opted for @ngrx/schematics as my default.

npm i @ngrx/schematics -D
ng config cli.defaultCollection @ngrx/schematics

That worked for me.