2

Why do I get this error, massive.connectSync is not a function when I run server.js. It works on my mac, but not my windows. Please help solve this enter code hereerror

var express = require("express");
var app = express();
var http = require('http');
var massive = require("massive");
var connectionString = "postgres://massive:@localhost/MarketSpace";

// connect to Massive and get the db instance. You can safely use the
// convenience sync method here because its on app load
// you can also use loadSync - it's an alias
var massiveInstance = massive.connectSync({connectionString : connectionString})

// Set a reference to the massive instance on Express' app:
app.set('db', massiveInstance);
http.createServer(app).listen(8080);
GoyaKing
  • 99
  • 7

1 Answers1

4

Synchronous functions are no longer supported, and the connect function itself no longer exists, it's all promises all the way:

var express = require("express");
var app = express();
var http = require('http');
var massive = require("massive");
var connectionString = "postgres://massive:@localhost/MarketSpace";

massive(connectionString).then(massiveInstance => {
    app.set('db', massiveInstance);
    http.createServer(app).listen(8080);
});

Note that massive requires node > 6. If you are using and older version you'll need to update node in order to use massive.

Docs

Andrés Andrade
  • 2,213
  • 2
  • 18
  • 23