Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

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

Closed
goldfire opened this Issue Jul 11, 2012 · 10 comments

Comments

Projects
None yet
7 participants

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?

Collaborator

ncb000gt commented Jul 11, 2012

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.

picaron commented Jul 13, 2012

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]

picaron commented Jul 13, 2012

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 https://github.com/polotek/libxmljs.git"
  3. cd libxmljs
  4. node-gyp configure
  5. node-gyp build

After I did that my libxmljs module worked correctly

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

Contributor

TooTallNate commented Jul 18, 2012

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

commit ac565d722bfee6a2efe5812f4389729c09378856
Author: Nathan Rajlich <nathan@tootallnate.net>
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).

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).

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

Collaborator

defunctzombie commented Jul 26, 2012

@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).

Contributor

TooTallNate commented Jul 26, 2012

@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.

Collaborator

defunctzombie commented Jul 26, 2012

You may know this but I don't. Simply put these other packages are not
yours so the developers can't just "know" this or assume it. It is nicer to
be explicit :)
On Jul 26, 2012 3:52 PM, "Nathan Rajlich" <
reply@reply.github.com>
wrote:

@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.


Reply to this email directly or view it on GitHub:
polotek#144 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment