George Valentin
George Valentin

Reputation: 668

Angular Animations is installed but I can't import it

I tried to install the Animations in my project.

C:\gtaui>npm install @angular/animations --save
[email protected] C:\gtaui
+-- @angular/[email protected]
`-- UNMET PEER DEPENDENCY @angular/[email protected]


npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\ch
okidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@
1.1.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}
)
npm WARN @angular/[email protected] requires a peer of @angular/[email protected] but no
ne was installed.

C:\gtaui>

I have the library in package.json

{
  "name": "gtaui",
  "version": "0.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "test": "ng test",
    "pree2e": "webdriver-manager update --standalone false --gecko false",
    "e2e": "protractor"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^4.1.1",
    "@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",
    "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"
  }
}

And after I add the animations module in application module:

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

I get the error:

ERROR in C:/gtaui/src/app/modules/app.ts (3,41): Cannot find module '@angular/pl atform-browser/animations'. ERROR in C:/gtaui/src/app/modules/app.ts (3,41): Cannot find module '@angular/pl atform-browser/animations'. webpack: Failed to compile.

Upvotes: 1

Views: 977

Answers (1)

Z. Bagley
Z. Bagley

Reputation: 9260

It gave you a nice warning to let you know: npm WARN @angular/[email protected] requires a peer of @angular/[email protected] but none was installed.

Update your package.json to "dependencies": { "@angular/animations": "^4.1.1", "@angular/common": "^4.1.1", "@angular/compiler": "^4.1.1", "@angular/core": "^4.1.1", "@angular/forms": "^4.1.1", "@angular/http": "^4.1.1", "@angular/platform-browser": "^4.1.1", "@angular/platform-browser-dynamic": "^4.1.1", "@angular/router": "^4.1.1", "core-js": "^2.4.1", "rxjs": "^5.0.1", "ts-helpers": "^1.1.1", "zone.js": "^0.7.2" }

And when npm says "requires a peer of" make sure you include it in your dependencies.

Upvotes: 1

Related Questions