1

I'm trying to connect to a postgre(heroku) with the sequelize. But the sequelize returns an error when starting my application

Help me us.

Error message returned when you run the command "node app.js":

$ node app.js
assert.js:42
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: false == true
    at Object.exports.connect (_tls_wrap.js:1036:3)
    at Socket.<anonymous> (C:\DaniloNote\Pessoal\Projetos-Testes\Node8AndSequelize\node_modules\pg\lib\connection.js:94:23)
    at Object.onceWrapper (events.js:315:30)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at TCP.onread (net.js:607:20)

My file package.json

   {
  "name": "teste",
  "description": "teste",
  "author": "danilo <[email protected]>",
  "version": "0.1.0",
  "engines": {
    "node": "8.11.1"
  },
  "dependencies": {
    "pg": "^7.4.2",
    "pg-hstore": "^2.3.2",
    "sequelize": "^4.37.7"
  }
}

My file app.js

const Sequelize = require('sequelize');

const sequelize = new Sequelize('database', 'username', 'password', {
  host: 'host',
  dialect: 'postgres',
    dialectOptions: {
                  ssl: true
              },
  pool: {
    max: 5,
    min: 0,
    acquire: 30000,
    idle: 10000
  }
});

sequelize
  .authenticate()
  .then(() => {
    console.log('Connection has been established successfully.');
  })
  .catch(err => {
    console.error('Unable to connect to the database:', err);
  });

This error happened when I updated my package to version 8 of the node.

Tks.

2
  • It's because of this: stackoverflow.com/questions/50203747/… Commented May 7, 2018 at 11:14
  • @vitaly-t, the problem was the pg module version. Thank you so much Commented May 7, 2018 at 12:48

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.