Error on counter function in Node.js library on Mac Os X

Hi,

I am encountering issues with running the ‘counter’ method on a bucket.
I’m running Mac Os X 10.9.5 and use couchbase v2.0.5

This is my test program:

var couchbase = require('couchbase');
var connection = new couchbase.Cluster('couchbase://myhostname'); 
var bucket = connection.openBucket();

bucket.counter('test', 1, {initial:1}, function(err, res) {
    console.log(err);
    console.log(res);
});

When I want to run this, I get issues with the binding, so it seems:

dyld: lazy symbol binding failed: Symbol not found: _ntohll
    Referenced from: <somepath>/node_modules/couchbase/build/Release/couchbase_impl.node
    Expected in: dynamic lookup

dyld: Symbol not found: _ntohll
    Referenced from: <somepath>/node_modules/couchbase/build/Release/couchbase_impl.node
    Expected in: dynamic lookup

Trace/BPT trap: 5

Other methods such as insert, upsert, get, … work perfectly, but the ‘counter’ method is giving me this particular issue.

How can I resolve this matter?

I’ve also tried installing the module with my own libcouchbase install, but that causes the whole app not to run anymore

brew install libcouchbase
npm install couchbase --couchbase-root=/usr/local/Cellar/libcouchbase

When i run my test now, it gives

<somepath>/node_modules/couchbase/lib/binding.js:152
  throw new Error('Failed to locate couchnode native binding' +
        ^
Error: Failed to locate couchnode native binding (maybe check builderror.log!)
    at Object.<anonymous> (<somepath>/node_modules/couchbase/lib/binding.js:152:9)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (<somepath>/node_modules/couchbase/lib/couchbase.js:3:15)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)

I also tried installing everything on a linux server, and there everything worked.
I feel I’m getting close, but for some reason the binding on Mac Os X is not working properly.

Anyone to the rescue?

Apparantly, when doing this on Mac Os X 10.10, the library works without a problem.
On 10.9.5 it gives this particular problem.

I managed to resolve the issue myself.
For reference: how I solved this on Mac OS X 10.9

In node_modules/couchbase/deps/lcb/gyp_config/mac/x64/config.h , I removed the following lines of code:

/* Have ntohll */
#include <arpa/inet.h>
#define HAVE_HTONLL

After running a manual node-gyp install, everything worked like a charm

cd node_modules/couchbase
node-gyp install

If you don’t have node-gyp, you can install it using

npm install -g node-gyp

Thank you for bringing this to our attention. We are investigating this further and will report back on a resolution. It appears, per running a repro I tested, and your resolution posted above, this is specific to node on OSX only.

This is actually related to an issue between MacOS, libcouchbase and Node.js. We have implemented a fix in libcouchbase as of recently, and it should be available in the next Node.js release on the first Tuesday of March.

Cheers, Brett

I have the same error on Windows 7 with Node.js, here is it:

D:\alles\Documents\_tellize\feed\node_modules\couchbase\lib\binding.js:152
  throw new Error('Failed to locate couchnode native binding' +
        ^
Error: Failed to locate couchnode native binding (maybe check builderror.log!)
    at Object.<anonymous> (D:\alles\Documents\_tellize\feed\node_modules\couchba
se\lib\binding.js:152:9)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (D:\alles\Documents\_tellize\feed\node_modules\couchba
se\lib\couchbase.js:3:15)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)

How can i fix this?

Hey derbl4ck,

What version of Node.js do you have installed? There are known issues with Windows and Node.js 0.12 compatibility at the moment that requires you to have a build environment available to use.

Cheers, Brett

Oh I have Windows 7 with node.js 0.12.0. Thank you :slight_smile:

Greets, Lukas

Take a look at the node-gyp project for information on what you need to have available for your build environment and you should be good to go!

Cheers, Brett

I have all what i need, but couchbase doesnt works. Does it work with node 0.11.9 ?

You should inspect the builderror.log file to identify why automatic building is failing.

Cheers, Brett

child_process: customFds option is deprecated, use stdio instead.
gyp ERR! build error 
gyp ERR! stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:267:23)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1067:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd D:\alles\Documents\_tellize\feed\node_modules\couchbase
gyp ERR! node -v v0.12.0
gyp ERR! node-gyp -v v1.0.2
gyp ERR! not ok

Hey derbl4ck,

This appears to be an issue with the node-gyp build system rather than our library. Please see the installation instructions for node-gyp to ensure you have everything configured properly.

Cheers, Brett

I have needed those steps to make it work without issue:

rm -rf node_modules 
npm install && npm rebuild

Then, in:

vim node_modules/couchbase/deps/lcb/gyp_config/mac/x64/config.h

Find:

/* Have ntohll */
#include <arpa/inet.h>
#define HAVE_HTONLL

Replace it with:

/* Have ntohll */
/* #include <arpa/inet.h> */
/* #define HAVE_HTONLL */

Then:

cd node_modules/couchbase
node-gyp install && node-gyp rebuild

If node-gyp is not installed:

npm install -g node-gyp