Error: More than one instance of bitcore-lib found.
Opened this issue ยท 23 comments
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)
@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.
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;
I had the exactly same trouble, and fixed by the exactly same workaround. not sure should I send a PR, though.
Worked for me too, after spending a day on it :(
It works, as long as you make the same correction to *all your instances of bitcore-lib/index.js
Same problem, same solution.
Thanx, @Johannbr !
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
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);
// }
};
The solution that @Johannbr suggested worked. If you have multiple bitcore libraries you need to return all the bitcore.versionGuard conditions
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
I have found a full proof solution to this ๐
Object.defineProperty(global, '_bitcore', { get(){ return undefined }, set(){} })
enjoy !!
@silence48 : no , not in version gaurd function . Put it as the init of your application or app.js .
@mathiasrw : do we need a PR to bitcore lib for this ? We can add this to our app instead .
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
@dagogodboss what if you don't want to use Bitcore-p2p ? I just want lib and explorers
Object.defineProperty(global, '_bitcore', { get(){ return undefined }, set(){} })
Where do I add that line?
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(){} })
fyi, last I looked into these things I found https://bcoin.io as a higher quality bitcoin javascript library
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