web-dev-qa-db-ja.com

ピアが必要ですが、何もインストールされていません

私の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.

メインアプリケーションに対する追加の警告があります。
なぜ、そしてこの警告を取り除く方法は?

7
lapots

TL; DR

Peer Dependenciesは、特別な種類の依存関係です。これらは、直接呼び出さないパッケージによって使用され、ユーザー(あなた)に制御を与えます。したがって、これらのパッケージを手動でインストールする必要があります。

package.jsonpeerDependenciesを追加する必要はありません。

これらのエラーが表示される理由は、依存関係の一部が[email protected]zone.js@^0.7.2package.jsonpeerDependenciesとして宣言しているためです。これが、package.jsonpeerDependenciesを追加したときに、これらの警告が2回表示される理由です。

Peer Dependenciesについてもっと理解するには、これらを読むことをお勧めします:

  1. ピアの依存関係
  2. NodeJSプロジェクトのPeerDependenciesは何ですか?
  3. これ 素晴らしい答え
1
yuval.bl

node_modulesフォルダーを削除し、npm installを実行します。エラーはなくなります。

0
Gundam Meister