ng generate @ angular / material:material-nav --name = main-nav无法正常工作

时间:2018-06-28 10:33:33

标签: angular-material angular6

即使ng generate @angular/material:material-nav --name home不起作用,我也确实有角度6,

得到类似的错误 Collection "@angular/material" cannot be resolved. Error: Collection "@angular/material" cannot be resolved. at NodeModulesEngineHost._resolveCollectionPath (/Users/mac/angular/retroAngular/node_modules/@angular-devkit/schematics/tools/node-module-engine-host.js:88:15) at NodeModulesEngineHost.createCollectionDescription (/Users/mac/angular/retroAngular/node_modules/@angular-devkit/schematics/tools/file-system-engine-host-base.js:106:27) at SchematicEngine._createCollectionDescription (/Users/mac/angular/retroAngular/node_modules/@angular-devkit/schematics/src/engine/engine.js:78:40) at SchematicEngine.createCollection (/Users/mac/angular/retroAngular/node_modules/@angular-devkit/schematics/src/engine/engine.js:71:43) at Object.getCollection (/Users/mac/angular/retroAngular/node_modules/@angular/cli/utilities/schematics.js:28:31) at GenerateCommand.getOptions (/Users/mac/angular/retroAngular/node_modules/@angular/cli/models/schematic-command.js:193:41) at GenerateCommand.<anonymous> (/Users/mac/angular/retroAngular/node_modules/@angular/cli/commands/generate.js:38:53) at Generator.next (<anonymous>) at /Users/mac/angular/retroAngular/node_modules/@angular/cli/commands/generate.js:7:71 at new Promise (<anonymous>)

2 个答案:

答案 0 :(得分:0)

这是因为尚未将@ angular / material添加到节点模块。首先使用ng add @angular/material安装@ angular / material,然后尝试生成组件

答案 1 :(得分:0)

应为ng generate @angular/material:material-nav --name=home名称后,您应该先输入=然后输入名称