找不到module /build/Debug/iconv.node

我试图在Ubuntu VM上运行node.js服务器。

我不断收到这个错误:

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) 

这行代码:

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

看起来像这样:

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

奇怪的是这个文件存在,当我捅我的目录结构:

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

所以我不确定为什么这个尝试catch块会被捕获。 实际上,正如我写的最后一句话,我决定尝试logging被捕获的错误。 它是:

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

不知道这是否有关,但我试着运行:

 node-gyp rebuild 

有了这个结果

gyp info it worked if it ends with ok gyp info using node-gyp@0.13.0 gyp info using node@0.10.26 | 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

好的,这就是我现在所拥有的一切。 如果我发现任何新的东西,将继续search解决scheme并在这里更新。

先谢谢您的帮助。 哦,请温柔 – 我是一个Linux的noob。

通过转到iconv目录并运行:

 node-gyp configure node-gyp build