Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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
like image 811
Meztli Avatar asked Oct 07 '20 02:10

Meztli


People also ask

How do you fix undefined properties Cannot be read?

Add undefined check on variable To fix the “cannot read property of undefined” error, check that the value is not undefined before accessing the property. For example, in this code: const auth = undefined; console. log(auth); // undefined // TypeError: Cannot read properties of undefined (reading 'user') console.

Can not read the property of undefined Reading 0?

The "Cannot read Property '0' of undefined" error occurs when accessing an undefined value at index 0 . To solve the error, initialize the variable to the correct data type, e.g. array or string, before accessing the index.

Can not read the property of undefined in jquery?

Undefined means that a variable has been declared but has not been assigned a value. In JavaScript, properties and functions can only belong to objects. Since undefined is not an object type, calling a function or a property on such a variable causes the TypeError: Cannot read property of undefined .


1 Answers

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
like image 197
Esteban Gehring Avatar answered Sep 29 '22 19:09

Esteban Gehring