Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Schematic "materialDashboard" not found in collection "@angular/material"

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?

like image 449
Pankaj Parkar Avatar asked Jul 14 '18 06:07

Pankaj Parkar


Video Answer


3 Answers

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
like image 140
Pankaj Parkar Avatar answered Oct 12 '22 22:10

Pankaj Parkar


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>
like image 42
Pier Nodoyuna Avatar answered Oct 12 '22 23:10

Pier Nodoyuna


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

like image 39
Aleksey K. Avatar answered Oct 13 '22 00:10

Aleksey K.