Ashvini Maurya
Ashvini Maurya

Reputation: 493

Module not found: Error: Can't resolve '@angular/animations'

After using "npm install" and starting local server by "npm start" I started getting this error:-

ERROR in ./~/@angular/material/@angular/material.es5.js
Module not found: Error: Can't resolve '@angular/animations' in '/home/ashvini/Desktop/HN-Angular2/node_modules/@angular/material/@angular'
 @ ./~/@angular/material/@angular/material.es5.js 20:0-81
 @ ./src/app/app.module.ts
 @ ./src/main.ts`enter code here`
 @ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts
webpack: Failed to compile.

This is related to angular material design but I am not able to understand what I need to do to resolve this issue.

Before "npm install" it was working fine.

Upvotes: 34

Views: 69497

Answers (4)

Himanshu Joshi
Himanshu Joshi

Reputation: 126

I search a lot seriously then I found that in my project

node_modules/@angular/

I have by mistake have to install file which due to error install half and named animation So as I delete that file error get solved.I think it may be due to multiple files on root and project folder.

Upvotes: -4

scottzh
scottzh

Reputation: 11

npm install will install the latest Angular Framework, which is now 4.

the solution is above mentioned already by others.

Cheers.

Upvotes: 0

Md Ghouse
Md Ghouse

Reputation: 311

In package.json remove (^) "@angular/material": "^2.0.0-beta.2". In latest angualr.material we are getting this error.

Upvotes: 6

SrAxi
SrAxi

Reputation: 20005

In app.module add this:

import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

And lather in the module add it to imports:

imports: [BrowserAnimationsModule]

And remove the @angular/animations import statement.

Maybe by applying npm install you updated your Angular version from v.2 to v.4.

UPDATE:

or just add this to your package.json (Choose the version you need):

"dependencies": {
    "@angular/animations": "^4.0.1",
}

Once you added this to your dependencies, apply npm install again.

UPDATE 2:

Even a quicker way:

npm install @angular/animations --save

Upvotes: 79

Related Questions