BrowserModule has already been loaded Error

后端 未结 10 2251
猫巷女王i
猫巷女王i 2020-12-08 18:56

I\'ve updated my application to RC6 and now i keep getting this error:

zone.js:484 Unhandled Promise rejection: BrowserModule has already been loade

相关标签:
10条回答
  • 2020-12-08 19:32

    I've encountered a simular problem. I have serveral lazyloading modules which all use BrowserAnimationModule(Includes BrowserModule).

    My solution first is to move the importation of this module from the child module to the root module as app.module.ts.

    //app.module.ts
    @NgModule({
        declarations: [  ],
        imports: [    BrowserAnimationsModule,]
    

    The second step is quite essential, you should also include the CommonModule in each child module .

    //lazychild.module.ts
    @NgModule({
      declarations: [  ],
      imports: [  CommonModule,]
    
    0 讨论(0)
  • 2020-12-08 19:33

    Remove all the import of "BrowserAnimationsModule" as well except from AppModule.

    0 讨论(0)
  • 2020-12-08 19:35

    as Described here Angular Issues Page you can make a Shared Module and add all imports in there just once and import that module everywhere you make a new module.

    0 讨论(0)
  • 2020-12-08 19:36

    In my case, I had using BrowserAnimationsModule in each component that is using material design, I removed all reference to "BrowserAnimationsModule" and I put BrowserAnimationsModule in main module.

    BrowserAnimationsModule has inculuded BrowserModule, this is the problem.

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