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:
- Reinstalling build-essentials
- Reinstalling mongoDB
- Downgrading nodejs to 0.10.22
- deleting the node_modules dir
- cleaing the npm cache
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!