sequelize/sequelize · error · Error

The "dialect" option must be a dialect class. Pass the class

Error message

The "dialect" option must be a dialect class. Pass the class exported by your dialect package instead.

What it means

The dialect option must be the dialect class itself (a constructor function), not a string like 'mysql' and not an instance. v6 accepted string dialect names; v7 requires importing the class from the dialect package and passing the class reference.

Source

Thrown at packages/core/src/sequelize-typescript.ts:489

    if ('dialectModule' in options) {
      throw new Error(
        'The "dialectModule" option has been replaced with an equivalent option specific to your dialect. Please refer to the documentation of your dialect at https://sequelize.org to learn about the alternative.',
      );
    }

    if ('typeValidation' in options) {
      throw new Error(
        'The typeValidation has been renamed to noTypeValidation, and is false by default',
      );
    }

    if (!options.dialect) {
      throw new Error('The "dialect" option must be explicitly supplied since Sequelize 4');
    }

    if (typeof options.dialect !== 'function') {
      throw new Error(
        'The "dialect" option must be a dialect class. Pass the class exported by your dialect package instead.',
      );
    }

    // Synchronize ModelDefinition map with the registered models set
    listenForModelDefinition(model => {
      const modelName = model.modelDefinition.modelName;

      // @ts-expect-error -- remove this disable once all sequelize.js has been migrated to TS
      if (model.sequelize === (this as Sequelize)) {
        const existingModel = this.models.get(modelName);
        if (existingModel) {
          this.#models.delete(existingModel);
          // TODO: require the user to explicitly remove the previous model first.
          // throw new Error(`A model with the name ${inspect(model.name)} was already registered in this Sequelize instance.`);
        }

        this.#models.add(model);

View on GitHub (pinned to 7e1deec499)

Solutions

  1. Import the dialect class and pass it: import { PostgresDialect } from '@sequelize/postgres'; dialect: PostgresDialect.
  2. Pass the class (no parentheses), not an instance of it.

Example fix

// before
new Sequelize({ dialect: 'mysql' });

// after
import { MySqlDialect } from '@sequelize/mysql';
new Sequelize({ dialect: MySqlDialect });
Defensive patterns

Strategy: type-guard

Type guard

function isDialectClass(v) {
  return typeof v === 'function' && !!v.prototype;
}
if (!isDialectClass(options.dialect)) {
  throw new Error('options.dialect must be a dialect class');
}

Prevention

When it happens

Trigger: Passing dialect: 'postgres' (string), dialect: someInstance, or grabbing the wrong export from the dialect package.

Common situations: v6->v7 migration passing dialect:'sqlite'; default-vs-named import confusion.

Related errors


AI-assisted analysis of sequelize/sequelize@7e1deec499 (2026-08-03). Data as JSON: /data/errors/f71b431e0c424d5f.json. Report an issue: GitHub.