Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: More than one instance of bitcore-lib found. #1457

Open
Johannbr opened this issue Jun 20, 2017 · 23 comments
Open

Error: More than one instance of bitcore-lib found. #1457

Johannbr opened this issue Jun 20, 2017 · 23 comments

Comments

@Johannbr
Copy link

Johannbr commented Jun 20, 2017

Hi
I'm trying to install a full node (https://bitcore.io/guides/full-node/), but I ran into this error:
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 depen

Previous environment:

node 6 and npm 3

Steps:
1- npm install -g bitcore
=> got an error
2- sudo npm install -g bitcore
3- sudo apt-get install libzmq3-dev build-essential
Then I read that you should not install it with root privileges
4- Remove npm and node from my system (even cache and tmp folder)
5- install nvm with node 4.8.3 and npm 2.15.11

Current environment:

nvm with node 4.8.3 and npm 2.15.11

Steps:
1- npm install -g bitcore
2- bitcored
=> Error: More than one instance of bitcore-lib found.

I don't know how to make it work. If you have any ideas ;-)

Log:
/home/johann/.nvm/versions/node/v4.8.3/lib/node_modules/bitcore/node_modules/insight-api/node_modules/bitcore-lib/index.js:12
throw new Error(message);
^

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.
at Object.bitcore.versionGuard (/home/johann/.nvm/versions/node/v4.8.3/lib/node_modules/bitcore/node_modules/insight-api/node_modules/bitcore-lib/index.js:12:11)
at Object. (/home/johann/.nvm/versions/node/v4.8.3/lib/node_modules/bitcore/node_modules/insight-api/node_modules/bitcore-lib/index.js:15:9)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object. (/home/johann/.nvm/versions/node/v4.8.3/lib/node_modules/bitcore/node_modules/insight-api/lib/blocks.js:4:15)
at Module._compile (module.js:409:26)

@raymondcarl
Copy link

@Johannbr Same issue for me. I had some struggles trying to install bitcore due to a permission error. Eventually I installed it. I went back and deleted the global and project level installations and bitcore, but still get the same error as above. I also went and manually deleted the bitcore packages from the global npm directory, but no joy.

@Johannbr
Copy link
Author

Hi,
I found a solution here:
Issue 1454

Well, this is far from a proper way to solve this issue, but you can get rid of this error by editing file

~/.nvm/versions/node/v4.8.3/lib/node_modules/bitcore/node_modules/insight-api/node_modules/bitcore-lib/index.js

line 7:
bitcore.versionGuard = function(version) {
Change it to:
bitcore.versionGuard = function(version) { return;

@joemphilips
Copy link

joemphilips commented Jul 18, 2017

I had the exactly same trouble, and fixed by the exactly same workaround. not sure should I send a PR, though.

@bitcoinbrisbane
Copy link

Worked for me too, after spending a day on it :(

@Fatima-yo
Copy link

It works, as long as you make the same correction to *all your instances of bitcore-lib/index.js

@AlexanderKozhevin
Copy link

Same problem, same solution.
Thanx, @Johannbr !

@pira
Copy link

pira commented Nov 8, 2017

newer versions are broken, see comments here: ad4e25e

@usab
Copy link

usab commented Dec 12, 2017

Same problem here. How did you guys fix it?
There is no file: ~/.nvm/versions/node/v4.8.7/lib/node_modules/bitcore/node_modules/insight-api/node_modules/bitcore-lib/index.js

@ltfschoen
Copy link

ltfschoen commented Dec 16, 2017

I just opened node_modules/bitcore-mnemoic/node_modules/bitcore-lib/index.js and commented out the following lines of code

bitcore.versionGuard = function(version) {
  // if (version !== undefined) {
  //   var message = '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.';
  //   throw new Error(message);
  // }
};

AquiGorka added a commit to FormulaMonks/universal-wallet that referenced this issue May 22, 2018
Beware: bitpay/bitcore#1457 (comment)
When using bitcore-explorers and bitcore-lib (this change) the above
error witl occur. To fix apply proposed solution directly to every
bitcore-lib/index.js file.
Keep an eye for bitpay/bitcore-explorers#41
@tinkerNamedFerro
Copy link

tinkerNamedFerro commented Jun 28, 2018

The solution that @Johannbr suggested worked. If you have multiple bitcore libraries you need to return all the bitcore.versionGuard conditions

@Neats29
Copy link

Neats29 commented Jan 17, 2019

try adding
"postinstall": "find ./node_modules/**/node_modules -type d -name 'bitcore-lib' -exec rm -r {} + && echo 'Deleted duplicate bitcore-libs'" to your package.json.
curtsey of @Tahseenm

@adiingit
Copy link

I have found a full proof solution to this 👍

Object.defineProperty(global, '_bitcore', { get(){ return undefined }, set(){} })

enjoy !!

@silence48
Copy link

@adiingit are you putting that in the versionguard function?

@mathiasrw
Copy link

@adiingit Great!

Any chance you could make a pull request with the change?

@adiingit
Copy link

adiingit commented Apr 3, 2019

@silence48 : no , not in version gaurd function . Put it as the init of your application or app.js .

@silence48
Copy link

@adiingit thanks I figured it out shortly after appreciate the fix

@adiingit
Copy link

adiingit commented Apr 3, 2019

@mathiasrw : do we need a PR to bitcore lib for this ? We can add this to our app instead .

@dagogodboss
Copy link

I think I found a very Good work Around with version control or editing the code in your node modules because to me that is a bad practice

var p2p     = require('bitcore-p2p');                           //p2p exports
var p2pMod  = require.cache[require.resolve('bitcore-p2p')];    //p2p module
var bitcore = p2pMod.require('bitcore-lib');   

Or

var p2p     = require('bitcore-p2p');                           //p2p exports    
var bitcore = require('bitcore-p2p/node_modules/bitcore-lib');  //p2p/bitcore-lib exports

https://stackoverflow.com/a/53814090/2618449

@morenoh149
Copy link

@dagogodboss what if you don't want to use Bitcore-p2p ? I just want lib and explorers

@Gabo1122
Copy link

Object.defineProperty(global, '_bitcore', { get(){ return undefined }, set(){} })

Where do I add that line?

@nyusternie
Copy link

I have found a full proof solution to this 👍

Object.defineProperty(global, '_bitcore', { get(){ return undefined }, set(){} })

enjoy !!

@adiingit's works great 👍

but if you're using bitcore-lib-cash, you have to change it to:

Object.defineProperty(global, '_bitcoreCash', { get(){ return undefined }, set(){} })

@morenoh149
Copy link

fyi, last I looked into these things I found https://bcoin.io as a higher quality bitcoin javascript library

@ink-web3
Copy link

ink-web3 commented Jan 3, 2023

Hi, I found a solution here: Issue 1454

Well, this is far from a proper way to solve this issue, but you can get rid of this error by editing file
~/.nvm/versions/node/v4.8.3/lib/node_modules/bitcore/node_modules/insight-api/node_modules/bitcore-lib/index.js
line 7:
bitcore.versionGuard = function(version) {
Change it to:
bitcore.versionGuard = function(version) { return;

Resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests