Cannot find module '@angular-devkit/schematics/tasks'

断了今生、忘了曾经 提交于 2020-05-09 06:34:28

问题


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)


回答1:


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




回答2:


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


来源:https://stackoverflow.com/questions/54150694/cannot-find-module-angular-devkit-schematics-tasks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!