When two packages interact, there may be API changes, resulting in incompatibility between the two packages. How can I detect API changes or incompatibilities between two packages?
So let's say library A (which we'll assume) depends on library B version Y. If you ship Y, then: no problem. Shipping a version lower than Y is a no-no, but things get interesting if you ship higher than Y. There is no hard and fast rule; often it will work fine. Usually, hard-breaks get a semver "major", so if Y is 3.2, shipping 3.5 might be fine, but 4.2 might break. But both of those are soft "might": neither is guaranteed. The only way to know is to try, ideally adding unit tests so you can check it quickly in the future.
What gets even more interesting is when you also need a package C that depends on B version Z, where Y and Z are different. Again, the only way to know the answer is to try.