Object #<MongoClient> has no method 'open' Object #<MongoClient> has no method 'open' express express

Object #<MongoClient> has no method 'open'


This is happening may be because you are using new version of mongodb it is working fine after I use mongodb driver version 1.4.

npm install mongodb@1.4.x


Take a look at the mongodb docs. Your mongoClient object is not what you think it is, and that why there isn't an open() method available.

Make your example code look more like theirs:

var MongoClient = require('mongodb').MongoClient  , assert = require('assert');// Connection URLvar url = 'mongodb://localhost:27017/myproject';// Use connect method to connect to the ServerMongoClient.connect(url, function(err, db) {  assert.equal(null, err);  console.log("Connected correctly to server");  db.close();});