When I try to generate angular material data-table, I am getting below error. Please guide me to resolve this error.
ng command used for generate the data-table:
ng g @angular/material:material-table --name=data-table
after executing above ng command I am getting below error in my terminal
Cannot find module '@angular-devkit/schematics'
Error: Cannot find module '@angular-devkit/schematics'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15)
at Function.Module._load (internal/modules/cjs/loader.js:529:25)
at Module.require (internal/modules/cjs/loader.js:658:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (C:\Users\Lenovo\my-wks\meanStackDemo\node_modules\@angular\material\schematics\ng-generate\table\index.js:10:22)
Please share your suggestion or guidance to resolve this. Thanks .
Happy Holidays!:-)
When I tried installing angular material to my project I got the same error like
Cannot find module '@angular-devkit/schematics/tasks' in angular 7
So I did
npm i @angular-devkit/schematics
npm i @angular-devkit/core
it resolves the problem.
Finally I got blow conclusion from this error.
'npm install --save @angular/material @angular/cdk @angular/animations hammerjs
'
for my case 'C:\Users\Lenovo\my-wks\meanStackDemo\contacts>' -- correct path
'C:\Users\Lenovo\my-wks\meanStackDemo>'--previous wrong path
now i can generate the data-table component by using below command
'ng g @angular/material:material-table --name=data-table
'
Thanks rvkant! your explanation is very useful to understand the issue.Thanks once again.
As per material design documentation
Blockquote Schematics are included with both @angular/cdk and @angular/material. Once you install the npm packages, they will be available through the Angular CLI.
Using the command below will install Angular Material, the Component Dev Kit (CDK), and Angular Animations in your project. Then it will run the install schematic.
ng add @angular/material
And then generate data-table component by using the following command
ng generate @angular/material:table <component-name>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With