{"action":"created","issue":{"url":"https://api.github.com/repos/npm/npm/issues/9074","labels_url":"https://api.github.com/repos/npm/npm/issues/9074/labels{/name}","comments_url":"https://api.github.com/repos/npm/npm/issues/9074/comments","events_url":"https://api.github.com/repos/npm/npm/issues/9074/events","html_url":"https://github.com/npm/npm/issues/9074","id":97412000,"number":9074,"title":"Wrong version installed for peerDependencies","user":{"login":"IgorAufricht","id":13379857,"avatar_url":"https://avatars.githubusercontent.com/u/13379857?v=3","gravatar_id":"","url":"https://api.github.com/users/IgorAufricht","html_url":"https://github.com/IgorAufricht","followers_url":"https://api.github.com/users/IgorAufricht/followers","following_url":"https://api.github.com/users/IgorAufricht/following{/other_user}","gists_url":"https://api.github.com/users/IgorAufricht/gists{/gist_id}","starred_url":"https://api.github.com/users/IgorAufricht/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IgorAufricht/subscriptions","organizations_url":"https://api.github.com/users/IgorAufricht/orgs","repos_url":"https://api.github.com/users/IgorAufricht/repos","events_url":"https://api.github.com/users/IgorAufricht/events{/privacy}","received_events_url":"https://api.github.com/users/IgorAufricht/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/npm/npm/labels/bug","name":"bug","color":"C40233"},{"url":"https://api.github.com/repos/npm/npm/labels/peerdependencies","name":"peerdependencies","color":"beefed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-27T08:32:11Z","updated_at":"2015-07-27T16:21:25Z","closed_at":null,"body":"When I create a new `package.json` file like this:\r\n```javascript\r\n{\r\n  \"name\": \"peerdep-test\",\r\n  \"version\": \"1.0.0\",\r\n  \"devDependencies\": {\r\n    \"grunt-karma\": \"~0.8.3\",\r\n    \"karma-junit-reporter\": \"~0.2.2\",\r\n    \"karma-webpack\": \"~1.5.1\"\r\n  }\r\n}\r\n```\r\n\r\nAnd run `npm install`, I get this error:\r\n```\r\nnpm ERR! peerinvalid The package karma@0.13.3 does not satisfy its siblings' peerDependencies requirements!\r\nnpm ERR! peerinvalid Peer karma-junit-reporter@0.2.2 wants karma@>=0.9\r\nnpm ERR! peerinvalid Peer grunt-karma@0.8.3 wants karma@~0.12.0\r\nnpm ERR! peerinvalid Peer karma-webpack@1.5.1 wants karma@>=0.12 < 1\r\n```\r\n\r\nWhy is this particular version of karma (0.13.3) installed as a peer dependency, when it obviously does not meet all the requirements (grunt-karma requires ~0.12.0)? If npm chose e.g. karma@0.12.37, all the peer dependency requirements would be satisfied. We can verify this by installing the version directly and then checking with `npm list`:\r\n\r\n```\r\n$ npm install karma@0.12.37\r\n(... install succeeds)\r\n\r\n$ npm list -depth 0\r\npeerdep-test@1.0.0 c:\\dev\\labs\\peerdepend\\test\r\n├── grunt@0.4.5\r\n├── grunt-karma@0.8.3\r\n├── karma@0.12.37\r\n├── karma-junit-reporter@0.2.2\r\n├── karma-webpack@1.5.1\r\n└── webpack@1.10.5\r\n(... no peer dependency issues here)\r\n```\r\n\r\nI'm using npm version 2:\r\n```\r\n$ npm --version\r\n2.13.3\r\n```\r\n\r\n(This issue does not exist in npm@3, since peer dependencies are not installed by npm@3 by default.)"},"comment":{"url":"https://api.github.com/repos/npm/npm/issues/comments/125261910","html_url":"https://github.com/npm/npm/issues/9074#issuecomment-125261910","issue_url":"https://api.github.com/repos/npm/npm/issues/9074","id":125261910,"user":{"login":"othiym23","id":418097,"avatar_url":"https://avatars.githubusercontent.com/u/418097?v=3","gravatar_id":"","url":"https://api.github.com/users/othiym23","html_url":"https://github.com/othiym23","followers_url":"https://api.github.com/users/othiym23/followers","following_url":"https://api.github.com/users/othiym23/following{/other_user}","gists_url":"https://api.github.com/users/othiym23/gists{/gist_id}","starred_url":"https://api.github.com/users/othiym23/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/othiym23/subscriptions","organizations_url":"https://api.github.com/users/othiym23/orgs","repos_url":"https://api.github.com/users/othiym23/repos","events_url":"https://api.github.com/users/othiym23/events{/privacy}","received_events_url":"https://api.github.com/users/othiym23/received_events","type":"User","site_admin":false},"created_at":"2015-07-27T16:21:25Z","updated_at":"2015-07-27T16:21:25Z","body":"My guess is that due to the way that the `npm@2` dependency resolution algorithm works, it installs a version of `karma` that matches the semver of the first `peerDependency` declaration that it sees (which, as is implied, is nondeterministically chosen). The situation you're encountering is a bug, but we'll have to discuss whether it's a bug worth our time to fix, because one of the reasons motivating the changes to `peerDepedendencies` in `npm@3` was exactly this kind of conflict.\r\n\r\nA way to work around this issue is simply to add `karma@~0.12.37` to your `devDependencies`, which has the added benefit of working with both `npm@2` and `npm@3` (which requires something like that to be there anyway). Thanks for the report!"}}