Angular 2:找不到模块' @ angular / animations / browser'

时间:2017-09-07 12:15:30

标签: angular angular-cli angular-animations angular2-toaster

我尝试安装Angular2-Toaster(https://github.com/Stabzs/Angular2-Toaster),在示例中我成功安装了npm install angular2-toaster,我可以输入withoud错误,但我怎么看我也需要动画所以我安装了:

npm install '@angular/animations' --save

但导入模块时出错:

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

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

我还尝试npm installnpm update -D && npm update -S

这是我的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 {}

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 个答案:

答案 0 :(得分:3)

你正在使用Angular v2,没有BrowserAnimationsModule,这个模块是Angular v4的一部分。实际上你不需要这个导入