Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Cannot find module '../build/default/libxmljs' error #144

goldfire opened this Issue · 10 comments

7 participants

James Simpson Nick Campbell Pascal Chouinard Geoffrey Grosenbach Nathan Rajlich David Buser Roman Shtylman
James Simpson

Node: 0.8.2
libxmljs: 0.5.4
OS: OS X 10.7.4

Just requiring libxmljs in my app gives this error:

Error: Cannot find module '../build/default/libxmljs'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)
    at Object.<anonymous> (/Users/James/Sites/goldfire/node_modules/libxmljs/lib/bindings.js:6:22)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:362:17)
{ [Error: Cannot find module '../build/default/libxmljs'] code: 'MODULE_NOT_FOUND' }

libxml2 already comes installed on Lion, am I missing something here?

Nick Campbell

We should probably consider using the bindings module by @tootallnate.

That'd help with this. If I get some time I'll commit the necessary changes.

Pascal Chouinard

I have the same error ... when I look at the bindings.js file, I see there is a try/catch block :

try {
    // node 0.6+
    module.exports = require('../build/Release/libxmljs');
} catch (e) {
    // node 0.4.x
    module.exports = require('../build/default/libxmljs');

it seems the generated executable in "../build/Release" isnt good so the catch block is executed.

I am on OS X 10.7.4 too and the exception actually thrown is :

[Error: dlopen(/Users/pascal/projets/sandbox/HotPie/node_modules/libxmljs/build/Release/libxmljs.node, 1): no suitable image found.  Did find:
/Users/pascal/projets/sandbox/HotPie/node_modules/libxmljs/build/Release/libxmljs.node: mach-o, but wrong architecture]
Pascal Chouinard

As a workaround, I recompiled easily from source :

  1. install "node-gyp" globally if its not installed already with npm: "npm install node-gyp -g"
  2. from your "node_modules" directory in your projet run "git clone"
  3. cd libxmljs
  4. node-gyp configure
  5. node-gyp build

After I did that my libxmljs module worked correctly

Geoffrey Grosenbach

@picaron's solution worked for me, but it would be nice to get this working from the basic npm package.

Nathan Rajlich

Here's a patch to use node-bindings. Apply at will:

commit ac565d722bfee6a2efe5812f4389729c09378856
Author: Nathan Rajlich <>
Date:   Wed Jul 18 10:23:00 2012 -0700

    Use node-bindings

    Gives better error output in situations like #144.

diff --git a/lib/bindings.js b/lib/bindings.js
index e2a9f6d..3446c1a 100644
--- a/lib/bindings.js
+++ b/lib/bindings.js
@@ -1,7 +1 @@
-try {
-    // node 0.6+
-    module.exports = require('../build/Release/libxmljs');
-} catch (e) {
-    // node 0.4.x
-    module.exports = require('../build/default/libxmljs');
+module.exports = require('bindings')('libxmljs');
diff --git a/package.json b/package.json
index ab5fb3a..c71cc01 100644
--- a/package.json
+++ b/package.json
@@ -16,6 +16,9 @@
 , "main" : "./index"
 , "engines" : { "node" : ">=0.4.7" }
+, "dependencies":
+  { "bindings": "*"
+  }
 , "devDependencies":
     "nodeunit": "*"

Also, the root of this problem would go away as soon as you guys publish a new version to npm, as node-gyp is already the default for this project, it just hasn't been published in a long time (node-waf is messing up here, compiling for the wrong architecture).

David Buser

Also seeing this same error. I haven't tried picaron's workaround, will wait patiently for the npm package to be updated.

I'm running node 0.8.3 and libxmljs@0.5.4 on Ubuntu 12.04 (32-bit).

David Buser

Today I installed node v0.8.4 and now libxmljs@0.5.4 is working for me under ubuntu. Go figure!

Roman Shtylman

@TooTallNate I recommend that you pin the bindings version when you suggest these patches to projects. It is not cool to have different versions of a codebase deploy in production settings (and yes, many people deploy using npm).

Nathan Rajlich

@shtylman The thing is, I know that node-bindings' API will never change, only bugfixes. So I'm always gonna recommend that people use the latest node-bindings, cause I promise it will always remain compatible with any node version.

Roman Shtylman
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.