Collection "@ angular / material" can not be resolved

1

I'm starting with angular and I ended up with a very strange error when trying to execute the command:

ng generate @angular/material:material-nav --name nav-menu

It apprehends me the following satck:

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

I have already tried to reinstall the @ angular / cli and also delete the folder node_modules, but nothing worked.

I'm in the environment:

     _                      _                 ____ _     ___
     / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
    / △ \ | '_ \ / _' | | | | |/ _' | '__|   | |   | |    | |
   / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
  /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                 |___/


 Angular CLI: 6.0.8
 Node: 8.11.2
 OS: darwin x64
 Angular: 6.0.6
 ... animations, common, compiler, compiler-cli, core, forms
 ... http, language-service, platform-browser
 ... platform-browser-dynamic, router

 Package                           Version
 -----------------------------------------------------------
 @angular-devkit/architect         0.6.8
 @angular-devkit/build-angular     0.6.8
 @angular-devkit/build-optimizer   0.6.8
 @angular-devkit/core              0.6.8
 @angular-devkit/schematics        0.6.8 (cli-only)
 @angular/cdk                      6.3.1
 @angular/flex-layout              6.0.0-beta.16
 @angular/material                 6.3.1
 @ngtools/webpack                  6.0.8
 @schematics/angular               0.6.8 (cli-only)
 @schematics/update                0.6.8 (cli-only)
 rxjs                              6.2.1
 typescript                        2.7.2
 webpack                           4.8.3
    
asked by anonymous 27.06.2018 / 19:19

1 answer

0

I had the same problem now and found the solution here:

link

Basically use:

ng add @angular/[email protected]

To add 6.2.1 instead of adding the last one. Why the latest version (6.3.0) has this bug you found.

    
28.06.2018 / 02:58