I was trying to create a dashboard using the following command:
ng generate @angular/material:materialDashboard --name myDashboard
When I executed the command, it resulted in an error:
Schematic "materialDashboard" not found in collection
"@angular/material". Error: Schematic "materialDashboard" not found in
collection "@angular/material".
at SchematicEngine.createSchematic (/Users/xyx/Desktop/Git/question-authoring-platform/node_modules/@angular-devkit/schematics/src/engine/engine.js:155:23)
at CollectionImpl.createSchematic (/Users/xyx/Desktop/Git/question-authoring-platform/node_modules/@angular-devkit/schematics/src/engine/collection.js:12:29)
at Object.getSchematic (/Users/xyx/Desktop/Git/question-authoring-platform/node_modules/@angular/cli/utilities/schematics.js:36:23)
at GenerateCommand.getOptions (/Users/xyx/Desktop/Git/question-authoring-platform/node_modules/@angular/cli/models/schematic-command.js:194:40)
at GenerateCommand.<anonymous> (/Users/xyx/Desktop/Git/question-authoring-platform/node_modules/@angular/cli/commands/generate.js:38:53)
at Generator.next (<anonymous>)
at /Users/xyx/Desktop/Git/question-authoring-platform/node_modules/@angular/cli/commands/generate.js:7:71
at new Promise (<anonymous>)
at __awaiter (/Users/xyx/Desktop/Git/question-authoring-platform/node_modules/@angular/cli/commands/generate.js:3:12)
at GenerateCommand.initialize (/Users/xyx/Desktop/Git/question-authoring-platform/node_modules/@angular/cli/commands/generate.js:30:16)
Even I tried for other commands for myTable
and matNavbar
ng generate @angular/material:materialNavbar --name matNavbar
ng generate @angular/material:materialTable --name myTable
The same error happened with the above two commands. Am I missing something?
Investigation turns out that the commands aliases for generation of materialShell
, materialDashboard
, materialNav
and materialTable
were removed from schematics/collection.json
of @angular/material
. Rather while using it you can only use kebab case form of them.
materialShell => material-shell
materialDashboard => material-dashboard
materialNav => material-nav
materialTable => material-table
Commit Here
So rather than using older command like this
ng generate @angular/material:materialNav --name my-navbar
use
ng generate @angular/material:material-nav --name my-navbar
In the official documentation
Install Schematics
ng add @angular/material
Generator Schematics
Navigation Schematic
ng generate @angular/material:material-nav --name <component-name>
Dashboard Schematic
ng generate @angular/material:material-dashboard --name <component-name>
Table Schematic
ng generate @angular/material:material-table --name <component-name>
You can install it using:ng generate @angular/material:dashboard --name myDashboard
For other components it will be:ng generate @angular/material:nav --name myNav
ng generate @angular/material:table --name myTable
Info about other s/node_modules/@angular/material/schematics/collection.json
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With