1

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.

1
  • thank you! Just approved your edit :) Commented Apr 14, 2020 at 10:19

2 Answers 2

4

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.

Sign up to request clarification or add additional context in comments.

Comments

1

4 years later the answer by lub is correct and helped me.

Here's what I did for anyone else who appreciates literal examples

require('dotenv').config();

module.exports =
{
    "development": {
      "username": process.env.MSSQL_USER,
      "password": process.env.MSSQL_PASSWORD,
      "database": process.env.MSSQL_DB,
      "host": process.env.MSSQL_HOST,
      "dialect": "mssql",
      "dialectOptions": {
        "options": {
            "encrypt": true
      }
    }    
    },
    "production": {
      "username": "root",
      "password": null,
      "database": "",
      "host": "",
      "dialect": "mysql"
    }
  }
  

1 Comment

Happy to hear, that my answer to my own question helps someone 4 years later!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.