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. Please make sure to require bitcore-lib and check that submodules do not also include their own bitcore-lib dependency." #1366

Closed
LAMike310 opened this issue Oct 27, 2015 · 17 comments

Comments

@LAMike310
Copy link

Hi,

I started a new EC2 instance, and I did a fresh install of node, git and nvm. I set the nvm to 0.12, and I did a sudo npm intsall bitcore and sudo npm install bitcore-explorers, along with a few other modules needed for my script. When I run the script, I get 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 dependency."

How can I fix this? Has anyone else run into a similar situation?

I'm using Ubunti 14.04 btw, and the script works fine on my local machine.

Thanks,

Mike

@braydonf
Copy link
Contributor

You may run into issues when installing multiple modules globally, as the bitcore-lib won't be shared across them, each with another instance of bitcore-lib, which will lead to issues with instanceof type handling when objects are passed between modules. More info: #1328

@LAMike310
Copy link
Author

So starting from a fresh AWS instance of Ubuntu 14.04, what would be a good way to install bitcore and bitcore explorers in a way that doesn't cause any errrors?

@braydonf
Copy link
Contributor

Are you trying to setup a full node?

https://bitcore.io/guides/full-node

@LAMike310
Copy link
Author

No I'm just trying to use the Bitcore Explorers API to look up UTXOs and create transactions.

@LAMike310
Copy link
Author

Oh maybe I can just use:

var bitcore = require('bitcore-lib');

instead of

var bitcore = require('bitcore')

I will test that out when I get home

@levino
Copy link

levino commented Nov 21, 2015

@braydonf This include guard stuff is really weird. Why do you have to do that? Nobody else is doing it in an npm package...

@fanatid
Copy link
Contributor

fanatid commented Nov 22, 2015

@levino
Copy link

levino commented Nov 22, 2015

@fanatid Sorry, but I do not see the connection here. Fact is: One cannot include (require) bitcore twice. It is setting a global variable "bitcore" and checks for it "not being present". The only reason behind this can be, that bitcore relies on global variables, which it should not. Checking for the type of instance should work anyhow, shouldn't it?

@fanatid
Copy link
Contributor

fanatid commented Nov 22, 2015

If you have two or more bitcore-lib instances than instanceof not worked.
details: #1164

@cosmoarunn
Copy link

The error thrown from index.js file,

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);
  }
};

you can either update the version or mark it 'undefined'.
PS: (It's not an issue of installing bitcore globally )

@levino
Copy link

levino commented Apr 15, 2017

No other library in the world does this. Should be removed.

@fanatid
Copy link
Contributor

fanatid commented Apr 15, 2017

How much libraries in the world uses instanceof for type checking? If somebody received this message this means that you probably doing something wrong.

@oojr
Copy link

oojr commented May 10, 2017

@braydonf whats the solution? I am using bitcore-lib and bitcore-explorers and receiving this error

@askucher
Copy link

askucher commented Jun 4, 2017

this validation should be removed

@dabura667
Copy link

Yeah it should... from your project folder run this as a temp solution:

find ./node_modules -type f -print0 | xargs -0 sed -i 's/global\._bitcore/__NULLVARsdfs6d/g'

@cuifengcheng
Copy link

** webpack.json

  • module.exports ={
  • resolve: {
  •  modules: [path.resolve('node_modules')],
    
  • }
  • }

@red-name
Copy link

So how can one use bitcore-lib and bitcore-explorers together?

I need this to read UTXOs and create transactions.

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

10 participants