4

when I try to add @angular/material to my project I get this error.
Using Angular Cli: 7.2.1, Node 11.6.0

Cannot find module '@angular-devkit/schematics/tasks'
   Error: Cannot find module '@angular-devkit/schematics/tasks'
   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:657:17)
   at require (internal/modules/cjs/helpers.js:22:18)
   at Object. (/Users/ricardobaeza/Projects/node_modules/@angular/material/schematics/ng-add/index.js:10:17)
   at Module._compile (internal/modules/cjs/loader.js:721:30)
   at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
   at Module.load (internal/modules/cjs/loader.js:620:32)
   at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
   at Function.Module._load (internal/modules/cjs/loader.js:552:3)

7
  • run this command npm i @angular-devkit/schematics Commented Jan 11, 2019 at 16:43
  • @Abhishek I went ahead and used that command and im still gettting that error Commented Jan 11, 2019 at 16:46
  • clear your cache Commented Jan 11, 2019 at 16:48
  • @Abhishek I cleared the cache with npm cache clear --force then I tried rm -r node_modules/ npm i but no luck Commented Jan 11, 2019 at 16:57
  • ok try this @angular/material @angular/cdk @angular/animations Commented Jan 11, 2019 at 17:00

4 Answers 4

11

This is happening because of your node_modules does not contain the material directory.

To add Material into your node_modules run below command

npm install --save @angular/material @angular/cdk @angular/animations hammerjs

After this, you can run below command

ng add @angular/material
Sign up to request clarification or add additional context in comments.

1 Comment

this still leaves me with an absurd amount of errors. I cant use any components. After doing this My console is literally overrun with errors.
5

Your @angular/material command is not install all the dependency currently that why throw error try to run @angular/material @angular/cdk @angular/animations install angular material.

For old version use:-

npm install --save @angular/material @angular/cdk @angular/animations

For latest version use:-

ng add @angular/material

For more information visit official site of angular material https://material.angular.io/guide/getting-started

The ng add command will install Angular Material, the Component Dev Kit (CDK), Angular Animations and ask you the following questions to determine which features to include

Edit: fixed dashes for npm install command

6 Comments

What does it mean? could you explain better what should we do?
do you mean npm install @angular/material @angular/cdk @angular/animations?
@Vinni If you are using old version of Angular Material then yes npm install — save @angular/material @angular/cdk @angular/animations or if you are using updated version of Angular Material then run ng add @angular/material.
ok but the point is that I started right now a new Angular project (9.1.4) and when I try to run ng add @angular/material I get this error: ``` Skipping installation: Package already installed An unhandled exception occurred: Cannot find module '@angular-devkit/schematics/tasks' ``` I really don't understand what should I do.
@Vinni Have you tried to remove node_module, cache clean command, inpm i and after all this run ng add @angular/material
|
0

I had this same issue, I was building the project from the scratch. For me what I did wrong is I was trying to run

ng add @angular/material

Before running the

npm install

Once I ran the "npm install" first and then tried to install materials, everything started to install properly without any issues. Its a very silly basic mistake which is worth to note for beginers like me :)

Comments

0

You should try below command:

npm install --save @angular/material @angular/cdk @angular/animations

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.