Kamalakannan Manivel
Kamalakannan Manivel

Reputation: 391

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

Upvotes: 14

Views: 25759

Answers (4)

Muhammad Daniyal
Muhammad Daniyal

Reputation: 88

Your @angular/material command is not installing all the dependencies currently, that is why it throws an error.

Try to run

npm i @angular/material @angular/cdk @angular/animations

Now again install angular material.

Upvotes: 1

karthi_03
karthi_03

Reputation: 339

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.

Upvotes: 23

Kamalakannan Manivel
Kamalakannan Manivel

Reputation: 391

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.

Upvotes: 8

rvkant
rvkant

Reputation: 180

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>

Upvotes: 3

Related Questions