Angular 2 : No NgModule metadata found

后端 未结 28 1263
盖世英雄少女心
盖世英雄少女心 2020-11-30 05:31

I\'m brand new to Angular 2 and attempting to follow along with a video tutorial I found. Despite following all of the steps, Angular just won\'t work; I get the following e

相关标签:
28条回答
  • 2020-11-30 05:52

    I had the same problem but none of all those solutions worked for me. After further investigation, I found out that an undesired import was in one of my component.

    I use setTimeout function in app.component but for any reason Visual Studio added import { setTimeout } from 'timer'; where it was not needed. Removing this line fixed the issue.

    So remember to check your imports before going further. Hope it may help someone.

    0 讨论(0)
  • 2020-11-30 05:53

    The issue is fixed only when re installed angular/cli manually. Follow following steps. (run all command under Angular project dir)

    1)Remove webpack by using following command.

    npm remove webpack
    

    2)Install cli by using following command.

    npm install --save-dev @angular/cli@latest
    

    after successfully test app, it will work :)

    if not then follow below steps.

    1) Delete node_module folder.

    2) Clear cache by using following command.

    npm cache clean --force
    

    3) Install node packages by using following command.

    npm install
    

    4)Install angular@cli by using following command.

    npm install --save-dev @angular/cli@latest
    

    Note :if failed,try again :)

    5) Celebrate :)

    0 讨论(0)
  • 2020-11-30 05:53

    I would recommend restarting the application. Most of the cases editor won't be able to detect the changes in the lazy loaded module.

    0 讨论(0)
  • 2020-11-30 05:53

    I had this issue when i cloned from a git repository and I had it resolved when I created a new project and re-inserted the src folder from the old project.

    The src folder is the only folder needed when deploying your angular application but you must reconfigure the dev environment, using this solution.

    0 讨论(0)
  • 2020-11-30 05:56

    you need to enable the ngModel directive. This is done by adding the FormsModule to the imports[] array in the AppModule.

    You then also need to add the import from @angular/forms in the app.module.ts file: import { FormsModule } from '@angular/forms';

    0 讨论(0)
  • 2020-11-30 05:58

    In my case, I was trying to upgrade my angular 6 project using ng update after that the entire universe collapse.

    I was trying to update my project using this commands:

    • ng update @angular/cli
    • ng update @angular/core
    • ng update @angular/material

    And then I found a problem with rxjs package and I run also this command. - npm install --save rxjs

    And then I get the error

    No NgModule metadata found

    I solve this by deleting my node_modules folder in the project root and then I run:

    • npm install

    That's is, all works nice.

    0 讨论(0)
提交回复
热议问题