将 sequelize-cli 配置更改为动态配置时出错

Error changing sequelize-cli configuration to dynamic configuration

我 运行 遇到了问题,正在尝试将 sequelize-cli 配置更改为动态配置,如 documentation 中所述。我在项目的根目录中创建了 .sequelizerc 文件,并将路径配置为 config.js.

在 运行 npx sequelize-cli db:migrate 之后我得到以下错误:

Sequelize CLI [Node: 12.14.1, CLI: 5.5.1, ORM: 5.21.3]

Loaded configuration file "config/config.js".

Using environment "development".

ERROR: Server requests authentication using unknown plugin sha256_password. See TODO: add plugins doco here on how to configure or author authentication plugins.

无论我在我的开发环境 (localhost) 还是在我的生产环境 (clearDB with heroku) 上尝试,我仍然收到相同的错误消息,无法连接到服务器。没有动态配置(*.json 中的配置)一切正常。

这是我的 .sequelizerc 文件的内容

const path = require('path');

module.exports = {
      'config': path.resolve('config', 'config.js'),
}

这就是我config.js

的内容
module.exports = {
  development: {
    username: process.env.DB_USER,
    password: process.env.DB_PASSWORD,
    database: process.env.DB_NAME,
    host: process.env.DB_HOST,
    dialect: 'mysql',
  },
  production: {
    username: process.env.DB_PROD_USER,
    password: process.env.DB_PROD_PASSWORD,
    database: process.env.DB_PROD_NAME,
    host: process.env.DB_PROD_HOST,
    dialect: 'mysql',
  }
};

无论我在我的开发环境 (localhost) 还是在我的生产环境 (clearDB with heroku) 上尝试,我仍然收到相同的错误消息,无法连接到服务器。没有动态配置(*.json 中的配置)一切正常。

好吧,试了半天,我发现,当我运行 npx sequelize-cli-commands.

时,我的环境变量是undefined

所以我只是将 require('dotenv').config(); 添加到我的 .config.js 现在它可以工作了。