我正在尝试使用sequelize连接到postgre(heroku)。 但是sequelize在启动我的应用程序时会返回错误
帮帮我吧。
运行命令“ 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)
我的文件package.json
{
"name": "teste",
"description": "teste",
"author": "danilo <danilovex@gmail.com>",
"version": "0.1.0",
"engines": {
"node": "8.11.1"
},
"dependencies": {
"pg": "^7.4.2",
"pg-hstore": "^2.3.2",
"sequelize": "^4.37.7"
}
}
我的文件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);
});
当我将程序包更新到节点的版本8时发生了此错误。
韩国社交协会