Error: Collection "@angular/material" cannot be resolved (Solved)


When this Error occurs?

Whenever you try to use Angular schemats by entering some command like

ng generate @angular/material:material-nav --name name-of-new-nav

Error shown after entering this command is -

Collection "@angular/material" cannot be resolved. Error: Collection "@angular/material" cannot be resolved. at NodeModulesEngineHost._resolveCollectionPath (/Users/jeremypeters/MEGA/development/learning/angular/material- learn/node_modules/@angular-devkit/schematics/tools/node-module-engine-host.js:88:15) at NodeModulesEngineHost.createCollectionDescription (/Users/jeremypeters/MEGA/development/learning/angular/material- learn/node_modules/@angular-devkit/schematics/tools/file-system-engine-host-base.js:106:27) at SchematicEngine._createCollectionDescription (/Users/jeremypeters/MEGA/development/learning/angular/material- learn/node_modules/@angular-devkit/schematics/src/engine/engine.js:78:40) at SchematicEngine.createCollection (/Users/jeremypeters/MEGA/development/learning/angular/material- learn/node_modules/@angular-devkit/schematics/src/engine/engine.js:71:43) at Object.getCollection (/Users/jeremypeters/MEGA/development/learning/angular/material- learn/node_modules/@angular/cli/utilities/schematics.js:28:31) at GenerateCommand.getOptions (/Users/jeremypeters/MEGA/development/learning/angular/material- learn/node_modules/@angular/cli/models/schematic-command.js:193:41) at GenerateCommand. (/Users/jeremypeters/MEGA/development/learning/angular/material- learn/node_modules/@angular/cli/commands/generate.js:38:53) at Generator.next () at /Users/jeremypeters/MEGA/development/learning/angular/material-learn/node_modules/@angular/cli/commands/generate.js:7:71 at new Promise ()

Solution

The Angular CLI version you are using seems to be broken. You will have to change your version to 6.2.1 To change it you can write this command

ng add @angular/material@6.2.1
Solution Worked 1 UpvotesUpvote
        
Solution Didn't Worked 0 DownvotesDownvote


Comments




Search