bitcore
bitcore copied to clipboard
Error: More than one instance of bitcore-lib found.
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.
@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 !
newer versions are broken, see comments here: https://github.com/bitpay/bitcore/commit/ad4e25ef1b562163c398518079e796f9f704afe6
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 :+1:
Object.defineProperty(global, '_bitcore', { get(){ return undefined }, set(){} })
enjoy !!
@adiingit are you putting that in the versionguard function?
@adiingit Great!
Any chance you could make a pull request with the change?
@silence48 : no , not in version gaurd function . Put it as the init of your application or app.js .
@adiingit thanks I figured it out shortly after appreciate the fix
@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
https://stackoverflow.com/a/53814090/2618449
@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