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.

Unexpected directive 'MatTab' imported by the module 'AppModule'. Please add a @NgModule annotation

See original GitHub issue

Bug, feature request, or proposal:

Bug.

What is the expected behavior?

Material components should be recognized.

What is the current behavior?

Throws error: “Unexpected directive MatXYZ…”.

What are the steps to reproduce?

Providing a StackBlitz/Plunker (or similar) is the best way to get the team to see your issue.
Plunker starter (using on @master): https://goo.gl/uDmqyY
StackBlitz starter (using latest npm release): https://goo.gl/wwnhMV

(1) Create a new app using angular CLI.
(2) Add Angular Material dependencies following the Getting Started doc: https://material.angular.io/guide/getting-started
(3) Try “ng serve” and view the page error.

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

N/A.

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

tsc --version
Version 2.6.1

ng --version
Angular CLI: 1.5.0
Node: 6.11.5
OS: linux x64

"dependencies": {
"@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",
"core-js": "^2.4.1",
"hammerjs": "^2.0.8",
"rxjs": "^5.5.2",
"zone.js": "^0.8.14"
},

Is there anything else we should know?

None of the material components works, MatList, MatTab, MatCheckbox, …

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

105reactions
willshowellcommented, Nov 7, 2017

You need to import MatTabModule, not MatTab.

2reactions
tonydrakecommented, Dec 29, 2018

wow - what an issue!! - was an import case issue (file on disk was blockPage.ts (and should have been blockpage.ts (import { BlockPage } from ‘./blockpage’; where not flagged as errors).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught Error: Unexpected directive 'MatFormField' imported ...
Uncaught Error: Unexpected directive 'MatFormField' imported by the module 'AppModule'. Please add a @NgModule annotation. app.component.html < ...
Read more >
Unexpected directive imported by the module please add a ...
A class that's already declared in another module, whether an app module, @NgModule, or third-party module. An array of directives imported from another...
Read more >
Unexpected directive 'Slides' imported by the module ...
Hi! I'm trying to build a very simple app: taking pictures, saving them in an array and then displaying with a slide component....
Read more >
unexpected directive imported by the module please add a ...
Coding example for the question unexpected directive imported by the module please add a @ngmodule annotation-angular.js.
Read more >
Please add a @Pipe/@Directive/@Component annotation.
Unexpected value 'BrowserAnimationsModule' declared by the module. ... import { SharedModule } from '. ... module 't'. Please add a @NgModule annotation.
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