私のpackage.json
は次のようになります
{
"name": "hello-world",
"version": "1.0.0",
"description": "The Hello World",
"author": "",
"license": "MIT",
"scripts": {
"start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",
"lite": "lite-server",
"postinstall": "typings install",
"tsc": "tsc",
"tsc:w": "tsc -w",
"typings": "typings"
},
"dependencies": {
"@angular/common": "~2.0.1",
"@angular/compiler": "~2.0.1",
"@angular/core": "~2.0.1",
"@angular/http": "~2.0.1",
"@angular/platform-browser": "~2.0.1",
"@angular/platform-browser-dynamic": "~2.0.1",
"@angular/router": "~3.0.1",
"@angular/upgrade": "~2.0.1",
"systemjs": "0.19.39",
"core-js": "^2.4.1",
"reflect-metadata": "^0.1.8",
"rxjs": "5.0.0-beta.12",
"zone.js": "^0.6.25",
"angular-in-memory-web-api": "~0.1.1",
"bootstrap": "4.0.0-alpha.4"
},
"devDependencies": {
"concurrently": "^3.0.0",
"lite-server": "^2.2.2",
"TypeScript": "^2.0.3",
"typings": "^1.4.0"
}
}
npm i
を実行すると正常に実行されますが、いくつかの警告が表示されます。
npm WARN [email protected] requires a peer of [email protected] but none was installed.
npm WARN [email protected] requires a peer of zone.js@^0.7.2 but none was installed.
これらの行をpackage.json
に追加しました
"peerDependencies": {
"rxjs": "5.0.0-rc.4",
"zone.js": "^0.7.2"
}
しかし、もう一度npm i
を実行すると、この警告が表示されます
npm WARN [email protected] requires a peer of [email protected] but none was installed.
npm WARN [email protected] requires a peer of zone.js@^0.7.2 but none was installed.
npm WARN [email protected] requires a peer of [email protected] but none was installed.
npm WARN [email protected] requires a peer of zone.js@^0.7.2 but none was installed.
メインアプリケーションに対する追加の警告があります。
なぜ、そしてこの警告を取り除く方法は?
TL; DR
Peer Dependenciesは、特別な種類の依存関係です。これらは、直接呼び出さないパッケージによって使用され、ユーザー(あなた)に制御を与えます。したがって、これらのパッケージを手動でインストールする必要があります。
package.json
にpeerDependencies
を追加する必要はありません。
これらのエラーが表示される理由は、依存関係の一部が[email protected]
でzone.js@^0.7.2
とpackage.json
をpeerDependencies
として宣言しているためです。これが、package.json
にpeerDependencies
を追加したときに、これらの警告が2回表示される理由です。
Peer Dependenciesについてもっと理解するには、これらを読むことをお勧めします:
node_modules
フォルダーを削除し、npm install
を実行します。エラーはなくなります。