Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dialect needs to be explicitly supplied as of v4.0.0

I have been working on a NodeJS project which uses PostgreSQL database. I am trying to implement migration to the database. Also, using Sequelize. After setting up the migration folder and config, it throws error while running db:migrate

The error is: "Dialect needs to be explicitly supplied as of v4.0.0"

like image 558
shumana chowdhury Avatar asked Oct 11 '17 17:10

shumana chowdhury


People also ask

What is dialect in Sequelize?

Sequelize is independent from specific dialects. This means that you'll have to install the respective connector library to your project yourself.

What is Sequelize in node JS?

Sequelize is a Node. js-based Object Relational Mapper that makes it easy to work with MySQL, MariaDB, SQLite, PostgreSQL databases, and more. An Object Relational Mapper performs functions like handling database records by representing the data as objects.


1 Answers

Solution for me was based on what I had set for my NODE_ENV variable.

echo $NODE_ENV

If you do not have anything set for that variable, try setting it with the following:

export NODE_ENV=development

If a value is present, make sure you have an entry in your config file for that value. For me, I like to use local. So I had to update my config to this:

{  local: {   username: 'root',   password: null,   database: 'database_dev',   host: '127.0.0.1',   dialect: 'postgres'   },  development: {   username: 'root',   password: null,   database: 'database_dev',   host: '127.0.0.1',   dialect: 'postgres'   },   test: {   username: 'root',   password: null,   database: 'database_test',   host: '127.0.0.1',   dialect: 'postgres'  },  production: {   username: 'root',   password: null,   database: 'database',   host: '127.0.0.1',   dialect: 'postgres'  } }   
like image 190
JPero Avatar answered Sep 20 '22 11:09

JPero