无法读取Angular 6中未定义的属性“条目”

时间:2018-09-14 13:30:53

标签: angular angular-cli angular-pwa

在任何人将此标记为重复之前,我已经尝试过所有已发布的解决方案,并且曾经去过GitHub问题,而在StackOverflow中,没有一个解决方案对我有用。

每当我尝试生成任何角度的内容时,都会出现此错误。这是在我安装@angular/pwa时开始的,尽管不确定是否完全是原因,因为我已经有一段时间没有在任何较早的应用程序中尝试过generate命令了。我完全卸载了nodejs,然后重新安装了它,删除了所有node_modules全局和本地的node_modules,都没有结果,请帮忙,因为有重复的组件和编辑它们,虽然虽然不多,但是感觉像是在完成任务拥有。预先感谢。

编辑

这是我附加--debug标志时出现的错误

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)

这就是我运行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 个答案:

答案 0 :(得分:1)

您可以通过两种方式解决此问题,

(i)重新安装NodeJS。从用户目录中删除node_modules文件夹,然后按 npm install

(ii)尝试将 @angular/pwa 软件包更新为提到的 here

版本〜0.7.5。

答案 1 :(得分:0)

在尝试使用原理图生成某些东西时,我遇到了类似的问题。 我尝试显式安装@schematics/angular并使用以下命令设置默认的cli集合:

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

它对我不起作用。

因此,由于我已经在项目中使用了ngrx,因此我选择了@ngrx/schematics作为默认设置。

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

对我有用。