【问题标题】:Error when trying to run Node.js Ubuntu project in Mac:尝试在 Mac 中运行 Node.js Ubuntu 项目时出错:
【发布时间】:2013-05-04 07:12:06
【问题描述】:

我正在使用 Node.js、Express.js 和 sqlite3 创建一个小型网站。 我在 Ubuntu 中开发了我的项目,并且一直在尝试让它在 Mac 上运行。

但是在我从我的存储库 svn 签出项目文件夹并尝试运行我的 app.js 文件后,我收到以下错误:

module.js:356
  Module._extensions[extension](this, filename);
                           ^
 Error: dlopen(/Users/cs205g1s13/BS/baby_skype_less/node_modules/sqlite3/build/Release/node_sqlite3.node, 1): no suitable image found.  Did find:
/Users/cs205g1s13/BS/baby_skype_less/node_modules/sqlite3/build/Release/node_sqlite3.node: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00
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> (/Users/cs205g1s13/BS/baby_skype_less/node_modules/sqlite3/lib/sqlite3.js:1:104)
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)

该网站在 Ubuntu 上运行良好。而且,Mac电脑有Node.js,sqlite3。任何关于为什么会发生这种情况的帮助将不胜感激。


我从我的 svn 存储库中删除了 node_modules,并将我的项目文件夹 svn checkout 到 mac 计算机中。当我执行 npm install sqlite3 时,出现以下错误:

$ npm install sqlite3

npm WARN package.json application-name@0.0.1 No README.md file found!
npm http GET https://registry.npmjs.org/sqlite3
npm http 304 https://registry.npmjs.org/sqlite3

sqlite3@2.1.7 安装 /Users/cs205g1s13/BS/playing/node_modules/sqlite3 节点gyp重建

Traceback (most recent call last):
File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp", line 15, in <module>
import gyp
File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 8, in <module>
import gyp.input
File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 15, in <module>
import multiprocessing
ImportError: No module named multiprocessing
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:415:16)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:784:12)
gyp ERR! System Darwin 11.4.2
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-          gyp.js" "rebuild"
gyp ERR! cwd /Users/cs205g1s13/BS/playing/node_modules/sqlite3
gyp ERR! node -v v0.10.4
gyp ERR! node-gyp -v v0.9.5
gyp ERR! not ok 
npm ERR! sqlite3@2.1.7 install: `node-gyp rebuild`
npm ERR! `sh "-c" "node-gyp rebuild"` failed with 1
npm ERR! 
npm ERR! Failed at the sqlite3@2.1.7 install script.
npm ERR! This is most likely a problem with the sqlite3 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls sqlite3
npm ERR! There is likely additional logging output above.

npm ERR! System Darwin 11.4.2
npm ERR! command "node" "/usr/local/bin/npm" "install" "sqlite3"
npm ERR! cwd /Users/cs205g1s13/BS/playing
npm ERR! node -v v0.10.4
npm ERR! npm -v 1.2.18
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/cs205g1s13/BS/playing/npm-debug.log
npm ERR! not ok code 0

【问题讨论】:

    标签: mysql node.js sqlite express


    【解决方案1】:

    您是否将您的 node_modules 文件夹签入到 svn 中?不要那样做。要修复它,请在您的 Ubuntu 机器上运行 npm rebuild。 sqlite 使用必须在宿主平台上编译的扩展。

    【讨论】:

    • 在 Ubuntu 中进行 npm 重建后,是否应该将 node_modules 文件夹推送到存储库中?
    • 没有。 svn 用于您项目的源代码。 node_modules 是安装的第三方软件。将您的 package.json 文件检查到 svn 中,但将 node_modules 排除在外。
    • 我按照您的指示进行操作,我的所有其他模块一切正常,但对于 sqlite3 却不行
    • 看来您可能没有正确的 python 版本,但我不知道您需要的详细信息。
    • 谢谢你的帮助:D
    猜你喜欢
    • 1970-01-01
    • 2011-08-10
    • 1970-01-01
    • 1970-01-01
    • 2021-07-09
    • 2016-03-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多