无法加载 c++ bson 扩展

无法加载 c++ bson 扩展

问题描述:

这里是一个完整的节点菜鸟.我一直在尝试设置示例节点应用程序,但每次尝试运行时都会弹出以下错误:

A total node noob here. I've been trying to set up a sample node app but the following error keeps popping up every time I try to run:

节点应用

Failed to load c++ bson extension, using pure JS version

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: failed to connect to [#$%67890 :27017]
    at null.<anonymous> (/home/thejazeto/code/nodejs/authen/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:553:74)
    at EventEmitter.emit (events.js:106:17)
    at null.<anonymous> (/home/thejazeto/code/nodejs/authen/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:140:15)
    at EventEmitter.emit (events.js:98:17)
    at Socket.<anonymous> (/home/thejazeto/code/nodejs/authen/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:512:10)
    at Socket.EventEmitter.emit (events.js:95:17)
    at net.js:830:16
    at process._tickCallback (node.js:415:13)

我猜您在安装 mongodb 库时没有可用的 make 工具.我建议你这样做

I guess you did not have the make tools available when you installed your mongodb library. I suggest you do

xcode-select --install(在 Mac 上)或 sudo apt-get install gcc make build-essential(在 ubuntu 上)

xcode-select --install (on a mac) or sudo apt-get install gcc make build-essential (on ubuntu)

然后运行

rm -rf node_modules
npm cache clean
npm install

或者只是基于@tobias 评论的 npm 更新(安装 build-essential 之后)

OR just npm update based on @tobias comment (after installing build-essential)

npm update