Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find module /build/Debug/iconv.node

I'm trying to run a node.js server on an Ubuntu VM.

I keep getting this error:

Error: Cannot find module '../build/Debug/iconv.node'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/vagrant/api/node_modules/geoipcity/node_modules/iconv/lib/iconv.js:27:14)
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> (/vagrant/api/node_modules/geoipcity/geoipcity.js:35:13)

The code around this line:

/vagrant/api/node_modules/geoipcity/node_modules/iconv/lib/iconv.js:27:14

Looks like this:

var bindings;
try {
  bindings = require('../build/Release/iconv.node');
}
catch (e) {
  bindings = require('../build/Debug/iconv.node');
}

The weird thing is that this file exists when I poke around my directory structure:

/vagrant/api/node_modules/geoipcity/node_modules/iconv/build/Release/iconv.node 

So I'm not sure why that try catch block is ever getting to catch. Actually, as I wrote that last sentence I decided to try to log the error that is caught. It was:

[Error: /vagrant/api/node_modules/geoipcity/node_modules/iconv/build/Release/iconv.node: invalid ELF header]

Not sure if this is relevant, but I tried running:

node-gyp rebuild

With this result

gyp info it worked if it ends with ok gyp info using [email protected] gyp info using [email protected] | linux | ia32 gyp info spawn python gyp info spawn args [ '/usr/lib/node_modules/node-gyp/gyp/gyp_main.py', gyp info spawn args 'binding.gyp', gyp info spawn args '-f', gyp info spawn args 'make', gyp info spawn args '-I', gyp info spawn args '/vagrant/api/build/config.gypi', gyp info spawn args '-I', gyp info spawn args '/usr/lib/node_modules/node-gyp/addon.gypi', gyp info spawn args '-I', gyp info spawn args '/home/vagrant/.node-gyp/0.10.26/common.gypi', gyp info spawn args '-Dlibrary=shared_library', gyp info spawn args '-Dvisibility=default', gyp info spawn args '-Dnode_root_dir=/home/vagrant/.node-gyp/0.10.26', gyp info spawn args '-Dmodule_root_dir=/vagrant/api', gyp info spawn args '--depth=.', gyp info spawn args '--no-parallel', gyp info spawn args '--generator-output', gyp info spawn args 'build', gyp info spawn args '-Goutput_dir=.' ] gyp: binding.gyp not found (cwd: /vagrant/api) while trying to load binding.gyp gyp ERR! configure error gyp ERR! stack Error: gyp failed with exit code: 1 gyp ERR! stack at ChildProcess.onCpExit (/usr/lib/node_modules/node-gyp/lib/configure.js:340:16) gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17) gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:797:12) gyp ERR! System Linux 3.2.0-23-generic-pae gyp ERR! command "node" "/usr/bin/node-gyp" "rebuild" gyp ERR! cwd /vagrant/api gyp ERR! node -v v0.10.26 gyp ERR! node-gyp -v v0.13.0 gyp ERR! not ok

Ok, that's about all I have for now. Will keep searching for a solution and update here if I find anything new.

Thanks in advance for the help. Oh, and please be gentle - I'm a Linux noob.

like image 844
Chris Avatar asked Mar 16 '14 02:03

Chris


1 Answers

Fixed by going to the iconv directory, and running:

node-gyp configure
node-gyp build
like image 114
Chris Avatar answered Nov 14 '22 12:11

Chris