运行“ng生成组件”时,本机脚本错误“无法读取未定义的属性“种类”

Mez*_*tli 5 typescript nativescript nativescript-angular angular

我无法向我的 Nativescript 项目添加新组件,当我执行ng generate component faqs它时返回错误:

Option "entryComponent" is deprecated: Since version 9.0.0 with Ivy, entryComponents is no longer necessary.
Cannot read property 'kind' of undefined
Run Code Online (Sandbox Code Playgroud)

或者如果我运行它就像ng generate component它问我组件名称一样

? What name would you like to use for the component? faqs
Run Code Online (Sandbox Code Playgroud)

并返回

Option "entryComponent" is deprecated: Since version 9.0.0 with Ivy, entryComponents is no longer necessary.
Cannot read property 'match' of undefined
Run Code Online (Sandbox Code Playgroud)

我在用:

Nativescript 7.0.10

Angular CLI: 10.1.4
Node: 12.18.4
OS: win32 x64

Angular: 10.1.4
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1001.4
@angular-devkit/core         10.0.8
@angular-devkit/schematics   10.1.4
@ngtools/webpack             10.1.4
@schematics/angular          10.1.4
@schematics/update           0.1001.4
rxjs                         6.6.3
typescript                   3.9.7
Run Code Online (Sandbox Code Playgroud)

我只是运行:

tns create HelloWorld
npm i --save-dev @angular/cli
npm install --save-dev @nativescript/schematics
npm install --save-dev @schematics/angular
Run Code Online (Sandbox Code Playgroud)

小智 7

根据https://github.com/NativeScript/nativescript-schematics/issues/302解决方案/解决方法是将打字稿更新到版本 4,即运行

npm install --save-dev typescript@4
Run Code Online (Sandbox Code Playgroud)

我测试了以下步骤,它似乎有效:

npm i -g @nativescript/schematics
ng new -c=@nativescript/schematics my-project --shared
cd my-project
npm install --save-dev typescript@4
ng g component bla
Run Code Online (Sandbox Code Playgroud)