mapbox/node-or-tools

Error: Cannot find module './binding/node_or_tools.node'

Closed this issue · 2 comments

When I try to install the example here: https://github.com/mapbox/node-or-tools/tree/master/example I get error:

 Error: Cannot find module './binding/node_or_tools.node'
     at Function.Module._resolveFilename (module.js:325:15)
     at Function.Module._load (module.js:276:25)
     at Module.require (module.js:353:17)
     at require (internal/module.js:12:17)
     at Object.<anonymous> (/Users/samir/Downloads/node-or-tools-master/lib/index.js:1:80)
     at Module._compile (module.js:409:26)
     at Object.Module._extensions..js (module.js:416:10)
     at Module.load (module.js:343:32)
     at Function.Module._load (module.js:300:12)
     at Module.require (module.js:353:17)

although I did:

npm install

and I can see node_or_tools is already installed:

npm WARN package.json node_or_tools_example@0.0.1 No repository field.

> node_or_tools@1.0.5 install /Users/samir/Downloads/node-or-tools-master/example/node_modules/node_or_tools
> node-pre-gyp install --fallback-to-build

[node_or_tools] Success: "/Users/samir/Downloads/node-or-tools-master/example/node_modules/node_or_tools/lib/binding/node_or_tools.node" already installed
Pass --update-binary to reinstall or --build-from-source to recompile

any idea?

Looks like the example simply requires the top level dir here:

var Solver = require('../');

but you have the library in your example's node_modules directory:

[node_or_tools] Success: "/Users/samir/Downloads/node-or-tools-master/example/node_modules/node_or_tools/lib/binding/node_or_tools.node"

The proper solution is to add the dependency to the example's package.json and then properly require it in the example. Not sure why we didn't do this in the first place.

What you also can do is:

  • remove node_modules directories from top level and example directory
  • npm install in the top level dir, then
  • npm install in the example dir

thanks, I've installed successfully now
your project is very interesting! 💘