javascriptmysqlnode.jssequelize.jssequelize-cli

Error changing sequelize-cli configuration to dynamic configuration


I am running into a problem, trying change the sequelize-cli configuration to dynamic configuration, as described in the documentation. I created the .sequelizerc-file in the root-directory of my project and configured the path to config.js.

After running npx sequelize-cli db:migrate I get the following error:

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.

It doesn't matter if I try it on my development environment (localhost) or on my production environment (clearDB with heroku) I still get the same Error message, not being able to connect to the server. Without the dynamic configuration (config in a *.json) everything worked fine.

This is the content of my .sequelizerc file

const path = require('path');

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

and this is simply the content of my 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',
  }
};

It doesn't matter if I try it on my development environment (localhost) or on my production environment (clearDB with heroku) I still get the same Error message, not being able to connect to the server. Without the dynamic configuration (config in a *.json) everything worked fine.


Solution

  • okay, after trying for a long time, I figured out, that my environment variables were undefined when I ran npx sequelize-cli-commands.

    So i simply added require('dotenv').config(); to my .config.js now it works.