Node couchbase module on Ubuntu server 12.04 throws “Invalid ELF header” error

I'm trying to install a node app with couchbase on an Ubuntu server.

I have downloaded Couchbase and installed it from here (as listed on download page): http://packages.couchbase.com/releases/2.2.0/couchbase-server-enterprise...

I can access it via web interface, it works fine.

Next, I try to install couchbase node module via npm:

npm install couchbase --save
This completes successfully. However when I try to run my app (which works fine on my desktop Ubuntu) I get this error:

ubuntu@aws-box:~/project/$ node index.js 
 
/home/ubuntu/project/node_modules/couchbase/lib/binding.js:16
  throw e;
        ^
Error:   
/home/ubuntu/project/node_modules/couchbase/prebuilt/win/x64/couchbase_impl.node: invalid ELF header
at Module.load (module.js:349:32)
at Function.Module._load (module.js:305:12)
at Module.require (module.js:357:17)
at require (module.js:373:17)
at bindings (/home/ubuntu/project/node_modules/couchbase/node_modules/bindings/bindings.js:74:15)
at tryLoadBinding (/home/ubuntu/project/node_modules/couchbase/lib/binding.js:13:31)
at Object.<anonymous> (/home/ubuntu/project/node_modules/couchbase/lib/binding.js:30:17)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:349:32)

What's going wrong?

prebuilt/win/x64/couchbase_impl for some reason your node is trying to load x64 blob for windows. maybe you should try to rebuild the module

Hmm, its the same folder layout in my Ubuntu Desktop where I crated the app - it runs OK there!

.... How does one build npm module??

I've made a patch that will stop it from erroring on the Windows binaries (http://review.couchbase.org/30889/). However, your system has an underlying issue that is causing it to fail to build the binary specific for your system. If you wouldn't mind, pastebin'ing the `npm install` command output so I can take a look.

Hi Brett, thank you for looking into this, I will paste the output as soon as I get to my laptop on Sunday evening.

Hi Brett, please find the log of the 'npm install couchbase --save --verbose' here: https://dl.dropboxusercontent.com/u/31550626/coucbase_install_log.txt

Is this what you needed? Please let me know if I can provide you with anything else. PS the OS is the Ubuntu server 12.04 that comes as an option on Amazon's free tier EC2 server.

Thank you for your help.

1 Answer

« Back to question.

Ensure that node-gyp works from your command-line before installing Couchnode. From what I can see, you may not have node-gyp available on the command line which is causing your systems couchnode build to fail.

Ok, I installed node-gyp globally. Calling it gives this output:

node-gyp@0.12.1  /usr/local/lib/node_modules/node-gyp
node@0.11.10-pre

I then re-installed couchbase locally in my project, and I still get the same error... Here's the update installation log file, if you need it: https://dl.dropboxusercontent.com/u/31550626/coucbase_install_log.txt

Would you be able to recommend something that I could try? I'm very new to node, and currently we are this one tiny step away from deploying the application. If I can't get the couchbase API working, we'll have to move to a different technology...

So, when you execute `node-gyp --version` from your command line it works fine? Also, where did you get node v0.11.10-pre? Perhaps you should try using v0.11.9 which is the latest version I've tested and know works.

That was the input from installing node-gyp like so npm install -g node-gyp. I initially installed node by downloading the linux 64bit package and running 'make' from nodejs.com. Is this the recommended place to get node from? I opted for downloading vs apt thinking that it'd be the latest working package... I'll try removing it and installing from apt maybe...

Try using a Node.js version manager such as `n` (https://github.com/visionmedia/n).

Thanks, I'll give it a go!

Hello,
I finally have a working version - I have installed Bitnami's Ubuntu+nodeJs image which has preconfigured node. Also, my friends have confirmed that installing via package managers yielded success. So, in conclusion - use package managers, because the latest build may not work for the given OS :) Thank you for your time.