Angular 2: Cannot find module '@angular/animations/browser'

3.9k views Asked by At

I'm tryng to install Angular2-Toaster (https://github.com/Stabzs/Angular2-Toaster), in the example I successful to install npm install angular2-toaster and I can inmport it withoud errors, but how I see I need also animations so I installed with:

npm install '@angular/animations' --save

but I have errors when I import the module:

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

with: Cannot find module '@angular/platform-browser/animations'

I try also npm install and npm update -D && npm update -S.

This is my app.module.ts:

import {BrowserModule} from '@angular/platform-browser';
import {NgModule, Component} from '@angular/core';
import {HttpModule} from '@angular/http';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {FormBuilder} from '@angular/forms';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; <- errors
import {ToasterModule, ToasterService} from 'angular2-toaster';

import {AppComponent} from './app.component';
... my components

@NgModule({
  declarations: [
    AppComponent,
    ... my components
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    BrowserAnimationsModule,
    ToasterModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule {}

The package.json:

{
  "name": "spring-boot-angular2-client",
  "version": "0.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "ng": "ng",
    "start": "ng serve --proxy-config proxy.conf.json",
    "test": "ng test",
    "pree2e": "webdriver-manager update --standalone false --gecko false",
    "e2e": "protractor"
  },
  "private": true,
  "dependencies": {
    "@angular/animation": "^4.0.0-beta.8",
    "@angular/animations": "^4.4.0-RC.0",
    "@angular/common": "^2.3.1",
    "@angular/compiler": "^2.3.1",
    "@angular/core": "^2.3.1",
    "@angular/forms": "^2.3.1",
    "@angular/http": "^2.3.1",
    "@angular/platform-browser": "^2.3.1",
    "@angular/platform-browser-dynamic": "^2.3.1",
    "@angular/router": "^3.3.1",
    "angular2-toaster": "^4.0.1",
    "bootstrap": "^3.3.7",
    "core-js": "^2.4.1",
    "rxjs": "^5.0.1",
    "ts-helpers": "^1.1.1",
    "zone.js": "^0.7.2"
  },
  "devDependencies": {
    "@angular/compiler-cli": "^2.3.1",
    "@types/jasmine": "2.5.38",
    "@types/node": "^6.0.42",
    "angular-cli": "1.0.0-beta.28.3",
    "codelyzer": "~2.0.0-beta.1",
    "jasmine-core": "2.5.2",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "1.2.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-remap-istanbul": "^0.2.1",
    "protractor": "~4.0.13",
    "ts-node": "1.2.1",
    "tslint": "^4.3.0",
    "typescript": "~2.0.3"
  }
}
1

There are 1 answers

2
Dmitry Ivanov On BEST ANSWER

You're using Angular v2, there are no BrowserAnimationsModule, this module is the part of the Angular v4. Actually you don't need this import