从v4.0.0开始,必须明确提供方言 [英] Dialect needs to be explicitly supplied as of v4.0.0

查看:523
本文介绍了从v4.0.0开始,必须明确提供方言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在研究一个使用PostgreSQL数据库的NodeJS项目。
我正在尝试实现向数据库的迁移。另外,使用Sequelize。设置迁移文件夹和配置后,在运行db:migrate

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

时会引发错误。错误是:
从v4开始需要明确提供方言.0.0

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

推荐答案

对我来说,解决方案基于我为 NODE_ENV 变量。

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

如果存在值 ,请确保您的配置文件中有一个那个值的条目。对我来说,我喜欢使用 local 。因此,我不得不将配置更新为:

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'
 }
}  

这篇关于从v4.0.0开始,必须明确提供方言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆