lapots
lapots

Reputation: 13405

requires a peer but none was installed

My package.json looks like this

{
  "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"
  }
}

When I run npm i it runs successfully but I got some warnings.

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.

I added these lines to package.json

"peerDependencies": {
    "rxjs": "5.0.0-rc.4",
    "zone.js": "^0.7.2"
}

But when I run npm i again I still get this warning

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.

with additional warning for the main application.
Why is that and how to get rid from this warning?

Upvotes: 8

Views: 9638

Answers (2)

yuval.bl
yuval.bl

Reputation: 5074

TL;DR

Peer Dependencies are a special kind of dependencies - they used by packages which do not call them directly, giving the user (you) the control. Hence, you have to install these packages manually.

You do not need to add peerDependencies to your package.json.

The reason you're seeing these error is, some of your dependencies declare [email protected] and zone.js@^0.7.2 in their package.json as peerDependencies. This is why when you've added peerDependencies in your package.json, you get these warning twice.

To understand more about Peer Dependencies I suggest reading these:

  1. Peer Dependencies
  2. What are those PeerDependencies in a NodeJS project?
  3. This great answer

Upvotes: 2

Gundam Meister
Gundam Meister

Reputation: 1495

I delete the node_modules folder and run npm install. The error would go away.

Upvotes: 0

Related Questions