Angular 2 : No NgModule metadata found

后端 未结 28 1261
盖世英雄少女心
盖世英雄少女心 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 06:08

    I had this error even though I had everything that the answers above suggested in place. A simple edit in the app.module.ts file ( like delete a bracket and put it back) did the trick.

    0 讨论(0)
  • 2020-11-30 06:09

    In your main.ts, you are bootstrapping both your AppModule and your App. It should just be the AppModule, which then bootstraps the App.

    If you compare your main.ts to the docs you'll see the difference - just remove all references to App from main.ts

    0 讨论(0)
  • 2020-11-30 06:10

    I've encountered this problem twice now. Both times were problems with how I was implementing my lazy loading. In my routing module I had my routes defines as:

      {
        path: "game",
        loadChildren: () => import("./game/game.module").then(m => {m.GameModule})
      }
    

    But this is wrong. After the second => you don't need curly braces. it should look like this:

      {
        path: "game",
        loadChildren: () => import("./game/game.module").then(m => m.GameModule)
     }
    
    0 讨论(0)
  • 2020-11-30 06:10

    Using ngcWebpack Plugin I got this error when not specifying a mainPath or entryModule.

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