Nativescript error 'Cannot read property 'kind' of undefined' when run 'ng generate component'
Asked Answered
P

2

5

I cannot add a new component to my Nativescript project, when I execute ng generate component faqs it returns the error:

Option "entryComponent" is deprecated: Since version 9.0.0 with Ivy, entryComponents is no longer necessary.
Cannot read property 'kind' of undefined

or if I run it like ng generate component it asks me the components name

? What name would you like to use for the component? faqs

and returns

Option "entryComponent" is deprecated: Since version 9.0.0 with Ivy, entryComponents is no longer necessary.
Cannot read property 'match' of undefined

I am using:

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

And I just run:

tns create HelloWorld
npm i --save-dev @angular/cli
npm install --save-dev @nativescript/schematics
npm install --save-dev @schematics/angular
Pedometer answered 7/10, 2020 at 2:4 Comment(2)
Did you solve this? It's really annoying how unsupported NativeScript is, even simple thing as running their demo project and creating a component inside breaks on a fresh installation and there is no documentation anywhere.Catton
Actually not, I avoid it. I create my component manually.Pedometer
K
7

According to https://github.com/NativeScript/nativescript-schematics/issues/302 the solution/workaround is to update typescript to version 4, i.e. run

npm install --save-dev typescript@4

I tested the following steps, and it seems to work:

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
Keitt answered 22/10, 2020 at 9:6 Comment(3)
I mean not. Now I can't run it. I get this: #63512718 And solution there is to downgrade the typescript. I'm in a infinite loop here.Catton
@Catton can you give more details about your setup? with the steps I performed above it worked for me. Did you make sure to update @angular-devkit/build-angular, etc.?Keitt
update: I created new project, followed your steps, but without installing anything globally. It works now.Catton
S
2

Error is mostly related to conflict between Angular, Node, NPM & TypeScript versions. I have seen it myself on some older Angular project when running and compiling. Although there is no definitive answer either from TypeScript or Angular github issues, following are many of the ways where you can reduce the conflicting files/folders and get rid of the issue:

  1. Delete node_modules and package-lock.json and reinstall the modules
  2. One of Angular ngtools version had a bug, which was causing the issue and is fixed
  3. Locally installed version of @angular/cli in project is different to globally installed version of @angular/cli.
  4. Changing/Replacing files while compile server is running, in this case stop the compiler before adding or removing a file

Besides that, you can also do further reading on the issues in the respective repositories of Typescript & Angular

Shotton answered 22/10, 2020 at 9:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.