Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Cannot find module '@angular-devkit/schematics' and Cannot find module '@angular-devkit/schematics'

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!:-)

like image 704
Kamalakannan.M Avatar asked Dec 27 '18 05:12

Kamalakannan.M


3 Answers

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.

like image 153
karthi_03 Avatar answered Nov 20 '22 10:11

karthi_03


Finally I got blow conclusion from this error.

1 make sure below command is executed in right directory or not.

'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.

like image 8
Kamalakannan.M Avatar answered Nov 20 '22 11:11

Kamalakannan.M


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>

like image 2
rvkant Avatar answered Nov 20 '22 10:11

rvkant