【问题标题】:Conflicting peerDependency on patch version mismatchConflicting peerDependency on patch version mismatch
【发布时间】:2022-12-02 03:33:52
【问题描述】:

I'm having basically the same problem as this Op npm peerDependency version conflict but nobody answered him.

My project (I'll call my-api) depends on a private library (let's call it package A) made by me, and this package A has another private library as a peerDependency (let's call it package B). Everything works fine only when my project installs the EXACT version of package B listed in package A peerDependencies. This is weird since package A lists his dependency like this:

{
"name: "package-a", 
"peerDependencies": {"package-b": "^0.0.8"}
}

and the dependency I'm installing in the project is "package-b": "^0.0.9" shouldn't ^0.0.9 satisfy ^0.0.8?

Here is the error message:

While resolving: my-api
npm ERR! Found: @a/package-b@0.0.9
npm ERR! node_modules/@a/package-b
npm ERR!   @a/package-b@"^0.0.9" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer @a/package-b@"^0.0.8" from @a/package-a@4.0.0
npm ERR! node_modules/@a/package-a
npm ERR!   @a/package-a@"^4.0.0" from the root project

npm error messages are so confusing to me!

I guess I could try using 0.x.x instead of ^0.0.8 but I still think it should work the way it is.

Edit: Just tried setting package-a dependency to: "package-b: 0.x.x" and I still get the same error

【问题讨论】:

    标签: npm npm-install npm-package


    【解决方案1】:

    Turns out my issue was because NPM doesn't follow the same rules when the major version of a package is 0.

    So basically to NPM 0.0.9 is completly different than ^0.0.8, but 1.0.9 is a valid patch version to ^1.0.8.

    To avoid this problem just start the packages at major version 1

    【讨论】:

      猜你喜欢
      • 2014-06-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-23
      • 1970-01-01
      • 2022-08-17
      • 2013-05-07
      • 1970-01-01
      相关资源
      最近更新 更多