大家好。有这样一个连接数据库的模块
const { Sequelize } = require('sequelize');
require('dotenv').config();
module.exports = new Sequelize(
process.env.DB_NAME,
process.env.DB_USER,
process.env.DB_PASSWORD,
{
dialect: 'postgres',
host: process.env.DB_HOST,
port: process.env.DB_PORT
}
);
在 index.js 这是代码
require('dotenv').config();
const express = require('express');
const PORT = process.env.PORT || 5000;
const sequelize = require('./db');
const app = express();
const start = async () => {
try {
await sequelize.authenticate();
await sequelize.sync();
app.listen(5000, () => {
console.log(`Server started on port ${PORT}`);
});
} catch (e) {
console.log(e);
}
};
start();
启动项目时,会抛出以下错误
据我了解,Sequalize 不喜欢方言,尽管一切似乎都写得正确。一般来说,我无法解决这个问题,我很乐意提供帮助!