cli: Can't run CLI without mysql client

If I attempt to use the CLI without the mysql client dependency, it fails:

robmaceachern$ node_modules/.bin/sequelize db:migrate

/Users/robmaceachern/workspace/work/caravan/node_modules/sequelize/lib/sequelize.js:163
      throw new Error('The dialect ' + this.getDialect() + ' is not supported.
            ^
Error: The dialect mysql is not supported. (Error: Please install mysql package manually)
    at new module.exports.Sequelize (/Users/robmaceachern/workspace/work/caravan/node_modules/sequelize/lib/sequelize.js:163:13)
    at Object.<anonymous> (/Users/robmaceachern/workspace/work/caravan/node_modules/sequelize-cli/lib/helpers/migration-helper.js:5:17)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at /Users/robmaceachern/workspace/work/caravan/node_modules/sequelize-cli/lib/helpers/index.js:12:54
    at Array.forEach (native)

The problem seems to be that migration-helper.js instantiates a Sequelize instance which is uses the mysql dialect as a default. It look it’s just using the instance to map model names to table names.

Workaround: Adding "mysql": "^2.3.2", to my project package.json allows the CLI to run properly.

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 16 (6 by maintainers)

Most upvoted comments

Haha, never mind, this is actually just a horribly unclear error message because the sequelize-cli code defaults to mysql instead of telling you what actually went wrong, to wit, it couldn’t find an option.