Sequelize error while trying to connect to database "Dialect needs to be explicitly supplied as of v4.0.0"

Asked

Viewed 33 times

0

I am trying to establish a connection to my postgres database using the sequelize, when I try to connect it accuses the following error, even with the dialect parameter being defined, yet it says it should be explicit

My code:

require('dotenv').config();
const express = require('express');
const app = express(); 
const { Sequelize } = require('sequelize');
const sequelize = new Sequelize(process.env.DB_NAME, process.env.DB_USER, {
    host:'localhost',
    dialect:'postgres'
});

try {
    sequelize.authenticate();
    console.log('Conexão estbabelecida com sucesso')
}catch{
    console.log('Erro ao estabelecer conexão');
}

const session = require('express-session');
const flash = require('connect-flash');

const routes = require('./routes')
const path = require('path');


app.use(express.urlencoded({  extended:true }));

app.use(express.static(path.resolve(__dirname, 'public')));

const sessionOptions = session({
    secret:process.env.cookie_secret,
    store: new (require('connect-pg-simple')(session))(),
    resave: false,
    saveUninitialized: false,
    cookie: {maxAge: 1000 * 60 * 60 * 24 * 7}
});

Error

Error: Dialect needs to be explicitly supplied as of v4.0.0 at new Sequelize (C: Users Lopes Desktop Javascript new-project Expressewebpack node_modules sequelize lib sequelize.js:281:13) at Object. (C: Users Desktop Javascript new-project Expressewebpack server.js:5:19) At module. _Compile (Internal/modules/cjs/Loader.js:1063:30) at Object.Module. _Extensions.. js (Internal/modules/cjs/Loader.js:1092:10) at Module.load (Internal/modules/cjs/Loader.js:928:32) at Function.Module. _load (Internal/modules/cjs/Loader.js:769:14) at Function.executeUserEntryPoint [as runMain] (Internal/modules/run_main.js:72:12) at Internal/main/run_main_module.js:17:47

  • There was a third parameter missing password before the object? see

  • I forgot to mention, my bank does not have a password, and when I put this parameter, it would show another error, where it said "client password must be a string", which I could not fix at all, where it is already declared

  • You passed null as a parameter or what?

  • If you use the file config.json, show him.

  • I haven’t passed null or anything, and I’m not using the json file

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.