Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

267
Visualizações
MatToolbar throws error when using it with Angular 9

Angular version 9.2.0

When I import the MatToolbarModule in a module and use it in the html template, then I get the following error message:

This likely means that the library (@angular/material/toolbar) which declares MatToolbarModule has not been processed correctly by ngcc, or is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.

8 export declare class MatToolbarModule {
                       ~~~~~~~~~~~~~~~~
src/app/angular-material.module.ts:53:14 - error NG6002: Appears in the NgModule.imports of ComponentsModule, but itself has errors

Does anyone face the same issue?

over 4 years ago · Santiago Trujillo
13 Respostas
Responde à pergunta

0

I had the same problem before, its because you modify your app.module.ts file while the server is running. Try to stop it and then run it again using the ng servecommand.

over 4 years ago · Santiago Trujillo Relatório

0

Add below specific configuration in package.json and npm install.

{
  "scripts": {
    "postinstall": "ngcc"
  }
}

Reference: https://angular.io/guide/ivy#speeding-up-ngcc-compilation

over 4 years ago · Santiago Trujillo Relatório

0

I solved it by removing the node_modules and reinstalled it.

Complete discussion here: https://github.com/angular/components/issues/18637

over 4 years ago · Santiago Trujillo Relatório

0

stop your angular service (if you use command prompt or powershell ctrl + c) and run again(ng serve)

over 4 years ago · Santiago Trujillo Relatório

0

I imported some classes(FormControl, FormGroup, Validators) which are not modules in app.module.ts
I removed those classes and it solved my problem.

over 4 years ago · Santiago Trujillo Relatório

0

I found an error in imports section, i've added unexisting item.

import { MatMenuItem } from '@angular/material/menu';

and MatMenut item doesn't exist, i changed in MatMenuModule and after works

over 4 years ago · Santiago Trujillo Relatório

0

This used to happen to me whenever I imported 'MatToolbar' 'MatDialog' instead of 'MatToolbarModule' or 'MatDialogModule'.

over 4 years ago · Santiago Trujillo Relatório

0

What worked for me is importing the whole module for MatToolbar.

import {MatToolbarModule} from '@angular/material/toolbar'; 

And then adding MatToolbarModule to the imports[] array in my app.module.ts.

over 4 years ago · Santiago Trujillo Relatório

0

So I was just having a similar issue, and I was able to fix it by rearranging my import modules.

In my case, I was calling LoadingBarRouterModule before the main module LoadingBarModule. Check to see if you are loading the MatToolbarModule module before another required module and move it below that.

over 4 years ago · Santiago Trujillo Relatório

0

Maybe the selected answer could not be the correct one because you may want bundle the dependency when you are building the application.

From https://angular.io/guide/ivy#speeding-up-ngcc-compilation

In version 9, the server builder which is used for App shell and Angular Universal has the bundleDependencies option enabled by default. If you opt-out of bundling dependencies you will need to run the standalone Angular compatibility compiler (ngcc).

I'm opting of restarting the server everytime i'm adding a material component into AppModule. But if i'm wrong, please let me know.

over 4 years ago · Santiago Trujillo Relatório

0

Here to me was because I forgot import a module.ts, and the console did not show about it. so, I only imported it and the angular worked ok. You can review all your modules.ts if there are some error with imports.

over 4 years ago · Santiago Trujillo Relatório

0

I faced similar problem with MatDatePicker. The problem was that I had imported MatDatepicker instead of importing MatDatepickerModule in the app.module.ts file.

So, check that you have imported MODULE not Component in your module file.

over 4 years ago · Santiago Trujillo Relatório

0

For me it was due to unused (or rather broken) ValueAccessors – removing them fixed this.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda