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

前端 未结 2 2023
既然无缘
既然无缘 2021-01-05 20:24

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

Option "entryCompon         


        
相关标签:
2条回答
  • 2021-01-05 20:40

    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

    • TypeScript Issue
    • Angular Issue
    0 讨论(0)
  • 2021-01-05 20:50

    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
    
    0 讨论(0)
提交回复
热议问题