2017-03-28 2 views
16

このリンクにある角度2ルーティングとナビゲーションの例を以下に示します。https://plnkr.co/edit/I4ArEQTniO7MJtfzpBWl?p=infoAugular 2 Router Animation - '@ angular/platform-b​​rowser/animations'モジュールを見つけることができません。

トランスペラレータを実行すると、エラーメッセージ "client/app/app.module.ts(5,41):error TS2307:モジュール '@ angular/platform-b​​rowser/animations'が見つかりません。

私のsystemjs.config.js(以下に示す)に基づいて、私はモジュール '@ angular/platform-b​​rowser/animations'をファイルにすることを期待します。 "platform-b​​rowser-animations.umd.js" node_modules/@ angular/platform-b​​rowser/bundlesがありますが、そこにはありません。私はその後、依存バージョンをインストールしようとしたが、満たされていない依存関係のメッセージを受信し続け

+-- UNMET PEER DEPENDENCY @angular/[email protected] 
+-- UNMET PEER DEPENDENCY @angular/[email protected] 
`-- UNMET PEER DEPENDENCY @angular/platform-bro[email protected] 

:欠落しているフレームワークをインストールしますが満たされていない依存関係のエラーメッセージが表示され、私がインストールしようとしたNPMを使用し

//systemjs.config.js 
(function (global) { 
    System.config({ 
    paths: { 
    // paths serve as alias 
    'npm:': 'node_modules/' 
    }, 
    // map tells the System loader where to look for things 
    map: { 
    // our app is within the app folder 
    app: 'app', 

    '@angular/animations': 'npm:@angular/animations/bundles/animations.umd.js', 
    '@angular/animations/browser': 'npm:@angular/animations/bundles/animations-browser.umd.js', 
    '@angular/core': 'npm:@angular/core/bundles/core.umd.js', 
    '@angular/common': 'npm:@angular/common/bundles/common.umd.js', 
    '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js', 
    '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js', 
    '@angular/platform-browser/animations': 'npm:@angular/platform-browser/bundles/platform-browser-animations.umd.js', 
    '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js', 
    '@angular/http': 'npm:@angular/http/bundles/http.umd.js', 
    '@angular/router': 'npm:@angular/router/bundles/router.umd.js', 
    '@angular/router/upgrade': 'npm:@angular/router/bundles/router-upgrade.umd.js', 
    '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js', 
    '@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js', 
    '@angular/upgrade/static': 'npm:@angular/upgrade/bundles/upgrade-static.umd.js', 

    // other libraries 
    'rxjs':      'npm:rxjs', 
    'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js' 
}, 
// packages tells the System loader how to load when no filename and/or no extension 
packages: { 
    //app: { 
    // main: './main.js', 
    // defaultExtension: 'js' 
    //}, 
    client: { 
    main: './main.js', 
    defaultExtension: 'js' 
    }, 
    rxjs: { 
    defaultExtension: 'js' 
    } 
} 
}); 
})(this); 

>npm install @angular/[email protected] @angular/[email protected] @angular/[email protected] --save 

私は角度4.

npm WARN @angular/[email protected] requires a peer of @angular/[email protected] but no 
ne was installed. 

をインストールする必要があることを示す1つの警告に気づいた私は、アニメーションが4.0インストールされているように見えますし、それは私がインストールしたくないコア4.0が必要です。アニメーション4.0をアンインストールし、以前のバージョンのアニメーションをインストールする必要がありますか?私のpackage.jsonファイルは以下の通りです。

//package.json 
{ 
"name": "angular-quickstart", 
"version": "1.0.0", 
"description": "QuickStart package.json from the documentation, supplemented with testing support", 
"scripts": { 
"build": "tsc -p client/", 
"build:watch": "tsc -p client/ -w", 
"build:e2e": "tsc -p e2e/", 
"serve:e2e": "lite-server -c=bs-config.e2e.json", 
"prestart": "npm run build", 
"start": "npm run build:watch", 
"pree2e": "npm run build:e2e", 
"e2e": "concurrently \"npm run serve:e2e\" \"npm run protractor\" --kill-others --success first", 
"preprotractor": "webdriver-manager update", 
"protractor": "protractor protractor.config.js", 
"pretest": "npm run build", 
"test": "concurrently \"npm run build:watch\" \"karma start karma.conf.js\"", 
"pretest:once": "npm run build", 
"test:once": "karma start karma.conf.js --single-run", 
"lint": "tslint ./client/**/*.ts -t verbose" 
    }, 
"keywords": [], 
"author": "", 
"license": "MIT", 
"dependencies": { 
"@angular/animations": "^4.0.0", 
"@angular/common": "^2.4.8", 
"@angular/compiler": "~2.4.0", 
"@angular/core": "^2.4.8", 
"@angular/forms": "~2.4.0", 
"@angular/http": "~2.4.0", 
"@angular/platform-browser": "^2.4.10", 
"@angular/platform-browser-dynamic": "~2.4.0", 
"@angular/router": "~3.4.0", 
"angular-animate": "^1.6.3", 
"angular-in-memory-web-api": "~0.2.4", 
"body-parser": "^1.17.0", 
"bootstrap": "^3.3.7", 
"cookie-parser": "^1.4.3", 
"core-js": "^2.4.1", 
"ejs": "^2.5.6", 
"express": "^4.15.0", 
"express-session": "^1.15.1", 
"jade": "^1.11.0", 
"jquery": "^3.1.1", 
"mongoose": "^4.8.5", 
"morgan": "^1.8.1", 
"passport": "^0.3.2", 
"passport-local": "^1.0.0", 
"rxjs": "5.0.1", 
"stylus": "^0.54.5", 
"systemjs": "0.19.40", 
"toastr": "^2.1.2", 
"zone.js": "^0.7.4" 
}, 
"devDependencies": { 
"concurrently": "^3.2.0", 
"lite-server": "^2.2.2", 
"typescript": "~2.0.10", 
"canonical-path": "0.0.2", 
"tslint": "^3.15.1", 
"lodash": "^4.16.4", 
"jasmine-core": "~2.4.1", 
"karma": "^1.3.0", 
"karma-chrome-launcher": "^2.0.0", 
"karma-cli": "^1.0.1", 
"karma-jasmine": "^1.0.2", 
"karma-jasmine-html-reporter": "^0.2.2", 
"protractor": "~4.0.14", 
"rimraf": "^2.5.4", 
"@types/node": "^6.0.46", 
"@types/jasmine": "2.5.36" 
}, 
"repository": {} 
} 

問題は私のアニメーションバージョンに関連する可能性がありますか?あなたが同意するならば、既存のバージョンをアンインストールする方法と、私が持っている@ angular/coreのバージョンと互換性のあるどのバージョンをインストールすればよいのですか。これが問題でない場合は、@ angle/platform-b​​rowser/bundles/platform-b​​rowser-animations.umd.jsファイルをどのようにインストールすればよいですか?

答えて

28

数時間にわたり研究したところ、私のバージョンである@ angular/coreの2.4.0-2.4.8のバージョンと互換性のある@ angular/animationsのバージョンは見つかりませんでした。私はこの記事の答え、How to get list of versions for compatible Angular 2 modules?を読んだ。この投稿は、ルータを除いて2番のすべてのモジュールが同じバージョンであることを示していましたので、私はangle/animations 2.4.8を私のpackage.jsonに接続し、すべてのバージョンを2.4.8に変更しました。私は何かを逃していなかった。私はnpmをインストールして実行しましたが、これはアニメーションバージョンでは失敗しました。

最終的にこの記事を見つけました。 http://angularjs.blogspot.com/をAngular 4.0に更新します。ポストには、失われていたアニメーションモジュールについての具体的な言及もありますが、アップグレードでのみ利用可能です。私はウィンドウのための簡単な更新の指示に従って、私のアプリケーションは現在正常に実行されています。私のアプリは、ガイドのプランナーの例に非常によく似ています。投稿ごとに、Angular 2.x.xを実行している場合、これはほとんどのアプリケーションで下位互換性があります。以下はアップグレードの手順です。あなたがアニメーションをしたい場合は4に4.0.0

更新に

更新は最新バージョン、およびダブルチェックにあなたの角度の依存関係を更新するのと同じくらい簡単です。これはほとんどのユースケースで機能します。Linux/Macの

:角度/ {普通、コンパイラ、コンパイラ-CLI、コア、フォーム、HTTP、プラットフォーム、ブラウザ、プラットフォームブラウザ - ダイナミック、プラットフォームサーバ、ルータ、アニメーション@

NPMをインストール} @latest typescriptです@最新--save Windows上

NPMは、角度/角度/コンパイラ@共通@最新の角度/ @最新@コンパイラ-CLI @角度/コア@最新@最新@angular @インストール/最新の@角度/プラットフォーム@最新の@角度/プラットフォームブラウザ@最新の@角度/プラットフォームブラウザ - 動的@最新@角度/プラットフォーム - サーバー@最新@角度/ルータ@最新@角度/アニメーション@最新t ypescript @最新--save

+2

ファンタスティック、フォローアップの@ J-テラノバを働いインストールNPM! – Geoffrey

+1

偉大な答え - 完璧に働いて、この問題については何も言わずに燃え尽きないようにしてくれました。 – Shane

+1

これは長い間私を困らせています。このソリューションは完璧です! –

2

ステップ-1

$ RM -rf node_modules

$ NPMのキャッシュをクリア

ステップ-2

ステップ以下試してみてください

$は/アニメーション角度@インストールNPM @最新--save

$が

その私のために

+0

'npm'の最新バージョンでは、' npm cache clear'コマンドはもう利用できません。キャッシュをきれいにする必要がある場合は、 'npm cache verify'または' npm cache clear --force'を実行しました。 –

関連する問題