Search code examples
angularangular-materialangular14angular15

Can´t find angular/material/theming after upgrade angular/Material15


After installing angular15, my application works correctly. But when installing angular/material15, pages lose some of their styles. Buttons are displaced, the font of the letters changes, div is moved. I noticed that there is an import that goes to a file that it does not find: @angular/material/theming. Can this be related? How can I get this file? Was renamed? Any hint please?

I use the next commands with the same result:

    ng add @angular/material
    npm install @angular/material@latest
    ng update @angular/material --force

Solution

  • First of all, if @angular/material/theming has a preceeding ~ then remove it.

    As for the lost styles this is because in Material 15 many components were completely re-written and others got a style updates. A migration tool is provided that helps you with the migration. For that run

    ng generate @angular/material:mdc-migration
    

    However, practically you'll probably still have to do a lot of manual changes depending on the complexity of your application. My advice when migrating is to migrate component by component and check your application each time for changes.

    Use this guide as a reference