在“@ angular / material”集合中找不到原理图“materialDashboard”

问题描述 投票:14回答:3

我试图使用以下命令创建仪表板:

ng generate @angular/material:materialDashboard --name myDashboard

当我执行命令时,它导致错误:

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)

甚至我也尝试过myTablematNavbar的其他命令

ng generate @angular/material:materialNavbar --name matNavbar
ng generate @angular/material:materialTable --name myTable

上述两个命令发生了同样的错误。我错过了什么吗?

angular angular-material
3个回答
43
投票

调查结果表明,从materialShellmaterialDashboard中删除了生成materialNavmaterialTableschematics/collection.json@angular/material的命令别名。而在使用它时,您只能使用它们的烤肉串案例形式。

materialShell => material-shell
materialDashboard => material-dashboard
materialNav => material-nav
materialTable => material-table

Commit Here

所以不要使用像这样的旧命令

ng generate @angular/material:materialNav --name my-navbar

使用

ng generate @angular/material:material-nav --name my-navbar

5
投票

在官方文档中

安装Schematics

ng add @angular/material

发电机原理图

导航示意图

ng generate @angular/material:material-nav --name <component-name>

仪表板原理图

ng generate @angular/material:material-dashboard --name <component-name>

表示意图

ng generate @angular/material:material-table --name <component-name>

3
投票

您可以使用以下方法安装它 ng generate @angular/material:dashboard --name myDashboard

对于其他组件,它将是: ng generate @angular/material:nav --name myNav ng generate @angular/material:table --name myTable

关于其他的信息 /node_modules/@angular/material/schematics/collection.json

© www.soinside.com 2019 - 2024. All rights reserved.