Failed to load c++ bson extension

Theja picture Theja · Feb 9, 2014 · Viewed 182.5k times · Source

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:

node app

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)

Answer

Pradeep Mahdevu picture Pradeep Mahdevu · Feb 26, 2014

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

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

and run

rm -rf node_modules
npm cache clean
npm install

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

npm update