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

查看:21
本文介绍了从 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.

回显 $NODE_ENV

如果您没有为该变量设置任何内容,请尝试使用以下设置:

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

导出 NODE_ENV=development

如果存在 is 值,请确保您的配置文件中有 那个 值的条目.对我来说,我喜欢使用 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天全站免登陆