With Angular 8, While building the app, we encounter the following error:
app/modules/admin-module/pages/editor/editor.component.ts:6:27 - error TS2306:
File ...node_modules/@angular/material/index.d.ts' is not a module.
With Angular 8, While building the app, we encounter the following error:
app/modules/admin-module/pages/editor/editor.component.ts:6:27 - error TS2306:
File ...node_modules/@angular/material/index.d.ts' is not a module.
This can be solved by writing full path, for example if you want to include MatDialogModule follow:
Before:
import { MatDialogModule } from "@angular/material"; //leading to error mentioned
After:
import { MatDialogModule } from "@angular/material/dialog"; //works fine
Do npm i -g @angular/material --save solve the problem
Seems like as this thread says a breaking change was issued:
Update: can confirm, this was the issue. After downgrading
@angular/material@9.0...
to@angular/material@7.3.2
we could solve this temporarily. Guess we need to update the project for a long term solution.After upgrading to Angular 9 (released today), I ran into this issue as well and found that they made the breaking change mentioned in the answer. I can't find a reason for why they made this change.
I have a material.module.ts file that I import / export all the material components (not the most efficient, but useful for quick development). I went through and updated all my imports to the individual material folders, although an index.ts barrel might be better. Again, not sure why they made this change, but I'm guessing it has to do with tree-shaking efficiencies.
Including my material.module.ts below in case it helps anyone, it's inspired off other material modules I've found: