Monday, March 14, 2016

TypeError: require(...).connect is not a function

I recently had  a hard time trying to fix this issue.
I initially wrote these lines below to establish my connection:

var databaseUrl = "localhost/school";
var collections = ["student", "professor"]
var db = require("mongojs").connect(databaseUrl, collections);
var http = require("http");


Now it seems that since 1.x , mongojs no longer support the connect function,
instead we should replace the third line with:


var db = require("mongojs")(databaseUrl, collections);


Source: https://github.com/mafintosh/mongojs/issues/286


 

No comments:

Post a Comment