AngularCLI and Angular Material (schematics) error: Collection “@angular/material” cannot be resolved

后端 未结 6 1217
眼角桃花
眼角桃花 2021-02-12 17:45

I am trying to use the Angular schemats that are shown on this page. When I try to use this following command in the terminal at the root of the project ng generate @ang

相关标签:
6条回答
  • 2021-02-12 18:08

    Try the following cmds, It worked for me :

    npm install --save @angular/material@6.2.1 @angular/cdk@6.2.1
    
    ng add @angular/material@6.2.1
    
    0 讨论(0)
  • 2021-02-12 18:09

    The Error is due to Angular Material 7. just run the following command in your terminal ng add @angular/material@6.2.1

    0 讨论(0)
  • 2021-02-12 18:09

    I found you're syntax wrong : ng generate @angular/material:nav <name-of-new-nav>.

    0 讨论(0)
  • 2021-02-12 18:11

    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 component schematics you can find in file, located in:
    /node_modules/@angular/material/schematics/collection.json

    0 讨论(0)
  • 2021-02-12 18:23

    It seems broken, Temp solution, use the following version

    ng add @angular/material@6.2.1
    
    0 讨论(0)
  • 2021-02-12 18:25

    Worked for me this way (from docs)

    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>
    

    Angular 6.4.7

    0 讨论(0)
提交回复
热议问题