javascript - Getting failed to load c++ bson extension error using Mongodb and Node.js -


i getting following error while trying run server using node.ja mongodb.

error:

{ [error: cannot find module '../build/release/bson'] code: 'module_not_found' }  js-bson: failed load c++ bson extension, using pure js version { [error: cannot find module '../build/release/bson'] code: 'module_not_found' }  js-bson: failed load c++ bson extension, using pure js version { [error: cannot find module '../build/release/bson'] code: 'module_not_found' }  js-bson: failed load c++ bson extension, using pure js version { [error: cannot find module '../build/release/bson'] code: 'module_not_found' }  js-bson: failed load c++ bson extension, using pure js version  c:\xampp\htdocs\odiya_chat\server.js:15 db = mongo.connect("127.0.0.1:27017/"+db, collections);            ^ typeerror: object function (connstring, cols) {   var dbname = getdbname(connstring);   var onserver = thunky(function(cb) {     gettopology(connstring, function(err, topology) {       if (err) return cb(err);       cb(null, topology);     });   });    if (!dbname) {     dbname = connstring._dbname;     onserver = thunky(function(cb) {       tomongodbcore(connstring, function(err, server) {         if (err) cb(new error('you must pass connection string or mongojs in stance.'));         cb(null, server);       });     });   }    var = new database({name: dbname, cols: cols}, onserver);   if (typeof proxy !== 'undefined') {     var p = proxy.create({       get: function(obj, prop) {         if (that[prop]) return that[prop];         that[prop] = that.collection(prop);         return that[prop];       }     });      return p;   };   return that; } has no method 'connect'     @ object.<anonymous> (c:\xampp\htdocs\odiya_chat\server.js:15:12)     @ module._compile (module.js:456:26)     @ object.module._extensions..js (module.js:474:10)     @ module.load (module.js:356:32)     @ function.module._load (module.js:312:12)     @ function.module.runmain (module.js:497:10)     @ startup (node.js:119:16)     @ node.js:929:3 

error-2

{ [error: cannot find module '../build/release/bson'] code: 'module_not_found' }  js-bson: failed load c++ bson extension, using pure js version { [error: cannot find module '../build/release/bson'] code: 'module_not_found' }  js-bson: failed load c++ bson extension, using pure js version { [error: cannot find module '../build/release/bson'] code: 'module_not_found' }  js-bson: failed load c++ bson extension, using pure js version { [error: cannot find module '../build/release/bson'] code: 'module_not_found' }  js-bson: failed load c++ bson extension, using pure js version 

my server side code given below.

server.js

var port=8888; var express=require('express'); var http=require('http'); var morgan         = require('morgan'); var bodyparser     = require('body-parser'); var methodoverride = require('method-override'); var cookieparser     = require('cookie-parser'); var session = require('express-session'); var mongodbstore = require('connect-mongodb-session')(session); var mongo = require('mongojs'); var app=express(); var server=http.createserver(app); db = 'doctor', collections = ['oditek'], db = mongo.connect("127.0.0.1:27017/"+db, collections); app.use(express.static(__dirname + '/public'));     // set static files location /public/img /img users app.use(morgan('dev'));                     // log every request console app.use(bodyparser.urlencoded({ extended: false }))    // parse application/x-www-form-urlencoded app.use(bodyparser.json())    // parse application/json app.use(methodoverride()); app.use(cookieparser()); //app.use(expresssession({secret:'somesecrettokenhere'}));                  // simulate delete , put app.get('/',function(req,res){     res.sendfile('view/index.html'); }) app.get('/login',function(req,res){     res.sendfile('view/login.html'); }); app.get('/chatroom',function(req,res){     if(req.session){         res.sendfile('view/chatroom.html');     } }); server.listen(port); console.log('server running on port'+port); 

here requirement if user logged in client side chatroom.html page , if not in client side ask login.i implementing here connect-mongodb-session store session.i have read posts regarding , tried answer still error there.please me resolve error.

since you're using mongojs module, you're going have connect database using following method

db = mongo("127.0.0.1:27017/"+db, collections); 

Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -