user3549889
user3549889

Reputation: 11

failed to load c++ bson

I'm new to this whole Nodejs, MongoDB, mongoose world. I'm just trying to follow some tutorials to get started and I keep getting this "Failed to load c++ bson extension, using pure JS version" error if I try and start any script with a reference to mongoose.

I've tried everything I can Google to fix it and nothing has worked including:

I'm at a loss. Can someone please help me out? I just want to get back to the learning!

I'm running both nodejs and MongoDB on a Ubuntu 13 server. This is my simple script.

var mongoose = require("mongoose");
mongoose.connect('mongodb://localhost/test');

var db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function () {
    var UsersSchema = mongoose.Schema({
        name: String
    });
    var User = mongoose.model('User', UsersSchema);
    var user = new User({ name: "SomeName" })
    user.save();
});

Thank you!

Upvotes: 1

Views: 855

Answers (2)

Youen
Youen

Reputation: 41

If you are using ubuntu 14.04 it may be related to this issue :

https://github.com/TooTallNate/node-gyp/issues/426

there are two methods to solve this problem:

upgrade gyp to the lastest version I found the --no-parallel option in svn source:https://code.google.com/p/gyp/source/browse/trunk/pylib/gyp/init.py

hack the node_gyp If you don't want upgrade your gyp, you can just comment line 316 of/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js

 argv.push('-Dvisibility=default')
 argv.push('-Dnode_root_dir=' + nodeDir)
 argv.push('-Dmodule_root_dir=' + process.cwd())
 argv.push('--depth=.')
 //argv.push('--no-parallel')

Upvotes: 1

Sumeet Kumar Yadav
Sumeet Kumar Yadav

Reputation: 12985

I also faced similar problem in initial setup , fixed it by re installing build-essential package

sudo apt-get install build-essential

and then re install mongodb native driver also

npm install mongodb

The current version of node is v0.10.26. Try upgrading your node version also.

Upvotes: 0

Related Questions