无法安装node-mongodb-driver

时间:2011-06-16 12:12:17

标签: mongodb node.js driver

我正在尝试使用git make node-mongodb-native驱动程序,但是当我尝试安装它时,我继续收到此错误:

:node-mongodb-native $ make  
make -C ./external-libs/bson  
rm -rf build .lock-wscript bson.node  
node-waf configure build  
Checking for program g++ or c++          : /usr/bin/g++   
Checking for program cpp                 : /usr/bin/cpp  
Checking for program ar                  : /usr/bin/ar  
Checking for program ranlib              : /usr/bin/ranlib  
Checking for g++                         : ok  
Checking for node path                   : not found  
Checking for node prefix                 : ok /Users/name/local/node  
'configure' finished successfully (0.087s)  
Waf: Entering directory `/Users/name/Sites/git/node-mongodb-native/external-libs/bson/build'  
[1/9] cxx: bson.cc -> build/default/bson_1.o  
[2/9] cxx: long.cc -> build/default/long_1.o  
[3/9] cxx: objectid.cc -> build/default/objectid_1.o  
[4/9] cxx: binary.cc -> build/default/binary_1.o  
[5/9] cxx: code.cc -> build/default/code_1.o  
[6/9] cxx: dbref.cc -> build/default/dbref_1.o  
[7/9] cxx: timestamp.cc -> build/default/timestamp_1.o  
[8/9] cxx: local.cc -> build/default/local_1.o  
[9/9] cxx_link: build/default/bson_1.o build/default/long_1.o build/default/objectid_1.o 
build/default/binary_1.o build/default/code_1.o 
build/default/dbref_1.o build/default/timestamp_1.o 
build/default/local_1.o -> build/default/bson.node  
Waf: Leaving directory `/Users/name/Sites/git/node-mongodb-native/external-libs/bson/build'  
'build' finished successfully (1.935s)  

node.js:183  
        throw e; // process.nextTick error, or 'error' event on first tick  
        ^  
Error: dlopen(/Users/name/Sites/git/node-mongodb-native/external-libs/bson/build/default/bson.node, 1): Symbol not found: _ev_rt_now  
  Referenced from: /Users/name/Sites/git/node-mongodb-native/external-libs/bson/build/default/bson.node  
  Expected in: flat namespace  
 in /Users/name/Sites/git/node-mongodb-native/external-libs/bson/build/default/bson.node  
    at Object..node (module.js:472:11)  
    at Module.load (module.js:339:31)  
    at Function._load (module.js:298:12)  
    at require (module.js:367:19)  
    at Object.<anonymous> (/Users/name/Sites/git/node-mongodb-native/external-libs/bson/test_bson.js:5:10)  
    at Module._compile (module.js:427:26)  
    at Object..js (module.js:466:10)  
    at Module.load (module.js:339:31)  
    at Function._load (module.js:298:12)  
    at Array.<anonymous> (module.js:479:10)  
make[1]: *** [all] Error 1  
make: *** [build_native] Error 2 

(为了便于阅读,分解了一些行)

对我来说可疑的部分是这一行:

Checking for node path : not found 

我的〜/ .bash_profile中有我的NODE_PATH:

export NODE_PATH=/usr/local/lib/node_modules::/usr/local/lib/node

当我ls这两个目录时,这就是我得到的:

$ ls /usr/local/lib/node
wafadmin -> ../../Cellar/node/0.4.8/lib/node/wafadmin
$ ls /usr/local/lib/node_modules
npm

我甚至只是尝试过我的NODE_PATH:

export NODE_PATH=/usr/local/lib/node_modules:/usr/local/lib/node:$HOME/local/node/lib/node_modules:$HOME/local/node/lib/node

我不认为它可能是最好的路径b​​ / c它在两个位置安装了节点,这可能导致不同的版本,但这不是重点。

有没有其他人在安装此驱动程序时遇到问题?

2 个答案:

答案 0 :(得分:1)

NPM是管理节点相关包的最佳选择。如果您已经有npm,那么您只需运行npm install -g mongodb。它会将节点mongo驱动程序安装到您的全局node_modules目录中。 如果您从其官方网站下载并安装节点,默认情况下将是npm。

答案 1 :(得分:0)

您运行的是哪个版本的节点?我使用的是v0.5.0-pre,我有同样的错误。一旦我降级到v0.4.8就行了。

brew install node

Or download v0.4.8 here