Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 2 - Module not found: Error: Can't resolve '@angular/material'

I followed each steps described here: https://material.angular.io/guide/getting-started

Error I get

ERROR in ./src/app/app.module.ts
Module not found: Error: Can't resolve '@angular/material' in '/Users/isabelle/my-project/src/app'
@ ./src/app/app.module.ts 14:0-51
@ ./src/main.ts
@ multi webpack-dev-server/client?http://localhost:4200/ ./src/main.ts

What I did

npm install -g @angular/cli
ng new my-project
npm install --save @angular/material

In src/app/app.module.ts

import { MaterialModule } from '@angular/material';
    
    // other imports 
@NgModule({
    imports: [MaterialModule],
    ...
})   
export class PizzaPartyAppModule { }
like image 969
Isabelle Avatar asked Feb 17 '17 10:02

Isabelle


3 Answers

I did that command again and everything ran smoothly

npm install --save @angular/material
like image 61
Isabelle Avatar answered Oct 14 '22 14:10

Isabelle


npm install --save @angular/material

npm install --save @angular/cdk

restart dev server

(usually the console will tell you when there are dependencies, pay attention to it)

like image 22
rychrist88 Avatar answered Oct 14 '22 14:10

rychrist88


Simply add it to your project

ng add @angular/material
like image 3
Uahmed Avatar answered Oct 14 '22 14:10

Uahmed