question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't register material icons anymore with version 5

See original GitHub issue

Bug, feature request, or proposal:

Bug Report

I’m using an Angular 5 project and have installed material @angular/cdk@^5.0.0-rc0 + @angular/material@^5.0.0-rc0. When I try to register custom SVG Icons for Mat-Icon, I get the error:

ERROR in Metadata version mismatch for module /Users/Me/dev/project/node_modules/@angular/material/core/typings/index.d.ts, found version 4, expected 3, resolving symbol AppSharedModule.

What is the expected behavior?

I would like to be able to register my svg Icons with IconRegistry of Material design without the version error.

constructor(iconRegistry: MatIconRegistry, sanitizer: DomSanitizer) {
    iconRegistry
    .addSvgIcon('my-icon',
        sanitizer.bypassSecurityTrustResourceUrl('/assets/svg/my-icon.svg'));
}

What is the current behavior?

The app throws the error:

ERROR in Metadata version mismatch for module /Users/Me/dev/project/node_modules/@angular/material/core/typings/index.d.ts, found version 4, expected 3, resolving symbol AppSharedModule.

What are the steps to reproduce?

Use Angular 5

    "@angular/animations": "^5.0.0",
    "@angular/cdk": "^5.0.0-rc0",
    "@angular/common": "^5.0.0",
    "@angular/compiler": "^5.0.0",
    "@angular/core": "^5.0.0",
    "@angular/forms": "^5.0.0",
    "@angular/http": "^5.0.0",
    "@angular/material": "^5.0.0-rc0",
    "@angular/platform-browser": "^5.0.0",
    "@angular/platform-browser-dynamic": "^5.0.0",
    "@angular/router": "^5.0.0",

Try to register icons e.g. AppModule/AppShared

export class MyClass {
    constructor(iconRegistry: MatIconRegistry, sanitizer: DomSanitizer) {
        iconRegistry
         .addSvgIcon('my-icon',
            sanitizer.bypassSecurityTrustResourceUrl('/assets/svg/my-icon.svg'));
    }
}

Npm start

npm start

What is the use-case or motivation for changing an existing behavior?

Get the project working

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

@angular/animations: 4.4.3 @angular/cdk: 5.0.0-rc0 @angular/common: 4.4.3 @angular/compiler: 4.4.3 @angular/core: 4.4.3 @angular/forms: 4.4.3 @angular/http: 4.4.3 @angular/material: 5.0.0-rc0 @angular/platform-browser: 4.4.3 @angular/platform-browser-dynamic: 4.4.3 @angular/router: 4.4.3 @angular/cli: 1.3.2 @angular/compiler-cli: 4.4.3 @angular/language-service: 4.4.3

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
EdricChan03commented, Jan 8, 2018

@ORESoftware First import is correct. Second import should be:

import {DomSanitizer} from '@angular/platform-browser';
1reaction
Jonathan002commented, Nov 10, 2017

Yeah I just found out now that there was something wrong with my npm. Even though I asked for Angular 5 in my package.json, each npm install gave me Angular 4. It was only until I removed my package-lock.json, was when npm successfully installed Angular 5. I now have the app running without this issue anymore. Thanks for the comments. : )

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular Material icons not working - Stack Overflow
Faced the issue when icon was not rendering and instead Close text was displaying. Appended the above import in my scss file and...
Read more >
Troubleshooting - Material Theme UI Documentation
A: Since 5.0.0, the icons related settings have been moved to the Atom Material Icons plugin, another plugin developed by the Material Theme...
Read more >
Compose Material - Android Developers
androidx.compose.material.icons ... Build Jetpack Compose UIs with ready to use Material Design Components. ... Version 1.0.5 contains these commits.
Read more >
material-icons - npm
Latest icon fonts and CSS for self-hosting material design icons. This package is automatically updated, so it will always have the latest icons...
Read more >
Material UI Tutorial #4 - Icons - YouTube
There's several ways to use Icons in material UI, in this tutorial we'll take a look at the most simple way to use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found