2
sudo npm install

result:

npm WARN karma-sinon-chai@1.3.4 requires a peer of sinon@>=2.1.0 <5 but none is installed. You must install peer dependencies yourself.

Vasan
  • 4,810
  • 4
  • 20
  • 39

2 Answers2

2

npm does not install dependencies specified as peerDependecy. This may seem unpleasing for people who used to bower, but that's no problem. You'll get used to it soon.

peerDependencies are dependencies that the package developer actually depends on it, but doesn't mention it as dependency. He/She/They (the developers) just suppose that wherever their package is going to be used, there will be karma-sinon-chai.

You need to install peerDependencys of a package yourself!

Ardeshir Izadi
  • 955
  • 1
  • 7
  • 25
  • there is no special way of installing `peerDependencies`. You just install it like any other dependency. `npm i karma-sinon-chai` And actually that's the reason that `npm` logs them as `WARN` so that you could see what peerDependencies there are & you could install it manually one by one – Ardeshir Izadi Feb 04 '19 at 04:59
  • BTW. If you know what you are doing and it doens't seem necessary to install `peerDependencies`, well you can ignore them. I ignore lots of them everyDay. (as an unwritten rule is that most of the time they exist) – Ardeshir Izadi Feb 04 '19 at 05:01
  • I'm new to npm and coming from iOS development where you are taught not to ignore any warnings (because of the framework's very strict safeties), it's hard for me to understand why or when you ignore these warnings. The terminal will say could not install `x` because `x` peer dependency needs to be installed manually. But you are saying to ignore this warning. Is that because the peer dependency really is installed? – lurning too koad Feb 04 '19 at 16:53
  • No! I mentioned "If you know what you are doing". The situations where I would use and define peerDependencies would be (for example) writing a library that must be used inside Angular-powered code, but I do not want to specifically mention dependency to Angular. As the user of my library may have other versions of dependency to Angular. Or I want to use another library in my library just like mine (which depends on Angular). And installing that library warns me "I need Angualr as PeerDependency", which in this case I can ignore it. – Ardeshir Izadi Feb 05 '19 at 04:54
  • Also another situation may be of kind `package x needs peerDependency package y@v0.7.2, but none found` and you have the same package, but a different version. In situations like this, you may be able to ignore them. – Ardeshir Izadi Feb 05 '19 at 05:01
  • 1
    There may be more situations which I can think of or are so specific. BTW, no! In JS world, you may learn to ignore warnings & most of the time only see errors. Especially in browsers' dev-tools console. : ) – Ardeshir Izadi Feb 05 '19 at 05:04
0

You can resolve this issue by running

npm i --legacy-peer-deps
mae
  • 14,947
  • 8
  • 32
  • 47