Using bitcore-lib in custom service failing

I am attempting to create a custom service that uses functionality from bitcore-lib. I am following the guide instructions as best I can. Most of the services examples do not include using bitcore-lib. I saw that Satoshi-Fire-Alarm did so I attempted to use the requires that I found in there:

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

It complains that it cannot find bitcore-lib. Looking at the project in github I see that it attempts to use relative paths to individual libraries which does not seem right. I tried it anyway and never had any luck loading bitcore-lib.

If I attempt to just use this:

var bitcore = require('bitcore');

it will complain that:

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.

I am not sure how I should go about requiring the core bitcore functionality in my service.

To be clear, when I remove the offending bitcore-lib specific code, my service gets loaded into bitcored. I only seem to be having an issue with require bitcore.

Also, I ran npm list -g and I only have bitcore@2.0.0 installed.

I created my project directory using “bitcore create projName” and symlinked my service into the resulting node_modules as per the instructions.

Any help would be appreciated.

Try using 0.13.9 release, there was an issue with the rename where the name wasn’t being exported properly that has been patched:

Edit: As relating to browser builds.

You should be able require(‘bitcore-lib’) from within a service, perhaps take a look at insight-api as reference?

To me the process seems a little convoluted and different packages give different instructions. You recommend using 0.13.9 release of what exactly? The install of bitcore with npm install -g bitcore (which is what I did) installs bitcore-node (I am assuming). Maybe it also installs bitcore-build which is what the link to your pull request was in.

I assume then that “bitcore create mynode” uses bitcore-build to build a copy of bitcore-node into the “mynode” directory. (again, this is what I did).

I tried cloning bitcore-node from github and ran the npm install to build it (without error) and symlinked it into my “mynode/node_modules” directory and it complains about not finding a binding file.

The biggest frustration is that most of your documentation says to set up things in different ways from the readme files to the full-node setup on the web page to the service development on the web page. Which of these pieces of documentation is the most correct? If I have bitcore installed (npm install -g bitcore) and a node built (bitcore create mynode) what is the best way to get bitcore-node in mynode updated?

Sorry about that, to be clear 0.13.9 was in reference in bitcore-lib.

bitcore-build is a collection of gulp tasks for automated testing and releases.

Currently, the best way to get bitcore-node updated from mynode is to run npm install inside of mynode, and if necessary adjust the versions in package.json.

My apologies for not getting back with you sooner. I was not able to follow up on my project until today. The version of bitcore-lib I have always been running is 0.13.9. I verified that is what was being used with npm list | grep lib. I went in a updated the package.json in my project and attempted to update it anywat with version >=v0.13.9 (not sure why this project is versioned with a v at the front but I followed the syntax already there). Nothing updated and I am still having this issue.

I found my issue. I am not sure if this is an OS thing or what. The library was not found in my service when my service was symlinked into the node modules of my bitcore node. I had to copy it directly.