More than one instance of bitcore-lib found

Hi All,
I have a following error, wath is it?

Error: More than one instance of bitcore-lib found. Please make sure to require bitcore-lib and check that submodules do not also include their own bitcore-lib dependency.

It looks like you’re using two different versions of bitcore-lib in your code. If bitcore-lib sees a bitcore class (eg: PrivateKey) that was created by a different version of bitcore-lib, it throws this error to prevent unexpected and hard to debug compatibility problems.

1 Like

Guys - please can this piece of big-brothering be removed? What is so different about bitcore that creates the necessity for this? It intermittently causes projects to stop working - whenever someone bumps a version up. It really isn’t worth the trouble it creates - and has cost us hours. Makes adoption of the bitcore suite that much more difficult.

It can be frustrating to find the duplicates if this happens. If you haven’t already, npm find-dupes bitcore-lib should help. As far as I understand npm@3 should help create flatter dependencies, and using peerDependencies may also help with the new behavior.

Yeah, this is extremely frustrating. I still don’t understand why Bitcore is the only package I’ve ever used that has this problem. You might want to rethink your particular multi-module design.

Yeah - again - today, bitcore-lib version is patched - and everything breaks again. If you guys are using semver, how about you raise this issue if there is an update or major - and leave things when you patch? BTW - find-dupes doesn’t find anything, and all the versions referenced look the same to me - could you please clearly justify why this is necessary?

Could we not make this configurable by environment variable or something?

Yeah this seems kind of broken. Because of this versionGuard, I can’t do this–

var PaymentProtocol = require('bitcore-payment-protocol'); var bitcoreLib = require('bitcore-lib');

That seems pretty sane to me, requiring two Bitcore libraries. How else am I supposed to accomplish that?

FYI I fixed this issue by forking bitcore-mnemonic and changing bitcore-lib to a peer dependency:

@insanity54 bitcore-payment-protocol shouldn’t be loading bitcore-lib on it’s own, and that should work. There was an issue a bit ago where each submodule was including bitcore-lib again, but was fixed.

@shea256 Great, I’ll give this a try with npm@3 as well, and if all is well I think we should move forward as using this for all the libraries.