1

我曾经npm install mongojs获取包装器,但是在尝试运行我的应用程序时出现以下错误:

node.js:195 
     throw e; // process.nextTick error, or 'error' event on first tick 
           ^
Native bson parser not compiled, please compile or avoid using  native_parser=true

然后我尝试从 github 获取源代码并自己编译 node-mongodb-native。然后在运行make时出现以下错误:

make -C ./external-libs/bson  
make[1]: Entering directory`/tmp/node-mongodb-native/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 
/usr/local 'configure' finished successfully (0.069s)  

Waf: Entering directory `/tmp/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  
../bson.cc:7:25: fatal error: node_events.h: No such file or directory  
compilation terminated. 
../objectid.cc:6:25: fatal error: node_events.h: No such file or directory  
compilation terminated.  
../code.cc:6:25: fatal error: node_events.h: No such file or directory  
compilation terminated. 
../dbref.cc:6:25: fatal error: node_events.h: No such file or directory  
compilation terminated.  
../long.cc:6:25: fatal error: node_events.h: No such file or directory  
compilation terminated. 
../binary.cc:7:25: fatal error: node_events.h: No such file or directory  
compilation terminated.  
Waf: Leaving directory `/tmp/node-mongodb-native/external-libs/bson/build'  
Build failed: -> task failed (err #1): 
     {task: cxx objectid.cc -> objectid_1.o}   -> task failed (err#1): 
     {task: cxx bson.cc -> bson_1.o}   -> task failed (err #1): 
     {task: cxx code.cc -> code_1.o}   -> task failed (err #1): 
     {task: cxx dbref.cc -> dbref_1.o}   -> task failed (err #1): 
     {task: cxx long.cc -> long_1.o}   -> task failed (err #1): 
     {task: cxx binary.cc -> binary_1.o}  make[1]: *** [all] Error 1  
make[1]: Leaving directory `/tmp/node-mongodb-native/external-libs/bson'  
make: *** [build_native] Error 2

关于为什么会失败以及如何使其工作的任何想法?

4

4 回答 4

1

在解决问题之前,您必须使用节点 0.5.1(您可以使用 gitk 将树恢复到此版本)

Auteur: Ryan Dahl <ry@tinyclouds.org>  2011-07-19 10:46:38
Auteur du commit: Ryan Dahl <ry@tinyclouds.org>  2011-07-19 10:46:38
Parent: 0a3fc1d9c8becc32c63ae736ca2b3719a3d03c5b (Remove StatWatcher's dep on C++ EventEmitter)
Enfant:  061ce7b0ac370c8a5ae93d95ab7da171cbd488f0 (net_uv: Fix simple/test-http-expect-continue.js)
Branche: master, remotes/origin/master
Suit: v0.5.1
Précède: v0.5.2
Finally remove node::EventEmitter
于 2011-09-01T00:10:43.380 回答
0

没有此类文件或目录编译终止错误可能意味着您尚未创建数据/数据库目录供 MongoDB 使用。

$ sudo mkdir -p /data/db/
$ sudo chown `id -u` /data/db

当我尝试使用 shell 连接到 MongoDB 时,我似乎记得看到过这样的事情。你能用shell连接吗???

于 2011-08-04T09:25:28.463 回答
0

Softwarepadawan,请升级到最新版本的Mongjs。今天下午我推送了一个修复这个问题的提交,并使用了 JS 解析器而不是原生解析器。

于 2011-09-20T14:32:01.163 回答
0

我认为您需要将 Node 添加到 .bashrc 中的 PATH 或任何文件中,具体取决于您的发行版。

请参阅此链接:http ://shapeshed.com/journal/setting-up-nodejs-and-npm-on-mac-osx/

于 2011-07-28T19:07:20.533 回答