Using following code snippet of node.js code connectiong mongodb running on windows:
var mongo = require("mongodb");
var host = "127.0.0.1";
var port = mongo.Connection.DEFAULT_PORT;
var db = new mongo.db("nodetest", new mongo.Server(host, port, {}));
db.open(function(error){
console.log("connected" + host + ":" + port);
});
Respective error is:
C:\nodetest\mongo.js:5
var db = new mongo.db("nodetest", new mongo.Server(host, port, {}));
^
TypeError: undefined is not a function
at Object.<anonymous> (C:\nodetest\mongo.js:5:10)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)
C:\nodetest>
Same code works on ubuntu well. Any pointers?
Thanks robertklep. The problem was with "Db". But "db" works fine with Ubuntu.