jean-Philippe jean-Philippe - 1 year ago 105
Node.js Question

error in pg-pool module when using postgres module with nodejs and heroku

I am trying to use a postgresql database within nodejs server application hosted with Heroku.

This is my code for pg in app.js:

var pg = require('pg');
pg.defaults.ssl = true;
pg.connect(process.env.DATABASE_URL, function(err, client) {
if (err) throw err;
console.log('Connected to postgres!');

and npm declaration file package.json:

"name": "utility-app",
"version": "0.0.1",
"ejs": "*",
"express": "3.3.x",
"pg": "6.0.1",
"simple-oauth2": "^0.7.0"
"node": "0.10.x",
"npm": "1.2.x"

This is working in my local environment but when i push the code to Heroku the server crashed:

Screenshot of console demonstrating the crash

Thank you for your help,


Answer Source

pg-pool is using an ES6 Promise, which isn't supported in the version of Node.js on your Heroku account, which is before 0.12.

You need to use a more modern version of Node.js, such as 4.x

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download