Try to use Shopify CLI (ES6) with Sequelize(common js) database

Topic summary

A developer is encountering compatibility issues when trying to integrate Sequelize (a database ORM that uses CommonJS/ES5 syntax) with Shopify CLI, which requires ES6 module syntax.

Problem Details:

  • Attempted to convert Sequelize configuration files from CommonJS to ES6 modules
  • Conversion is causing errors despite updating import/export statements
  • Shared code examples show converted model and configuration files using ES6 syntax (import/export instead of require/module.exports)

Current Status:

  • The issue remains unresolved
  • A second developer has encountered the identical problem and is also seeking solutions
  • No working solutions or workarounds have been provided yet

The discussion appears to contain some corrupted or reversed text in the configuration file example, which may indicate formatting issues in the original post.

Summarized with AI on November 22. AI used: claude-sonnet-4-5-20250929.

I’m going to use Shopify CLI with Sequelize database but it’s not compatible with ES6.

I tried to change the Sequelize (ES5, common js) files to the ES6 module but it’s giving me problems. If you have any suggestions or you did this type of work ES5/commonjs to ES6 module. Please help.

‘bundle.js’ Sequelize model file.

'use strict';
import { Model } from 'sequelize';
export default (sequelize, DataTypes) => {
  class bundle extends Model {
    static associate(models) {
      // define association here
    }
  };
  bundle.init({
    storeId: DataTypes.BIGINT,
    name: DataTypes.STRING,
    qty: DataTypes.INTEGER,
    price: DataTypes.STRING,
  }, {
    sequelize,
    modelName: 'bundle',
  });
  return bundle;
};

‘index.js’ Sequelize configuration file.

'use strict';

import fs from 'fs';
import path from 'path';
import Sequelize from 'sequelize';
import dbConfig from '../config/config.js';
import * as url from 'url';

const __filename = url.fileURLToPath(import.meta.url);
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));

const env = process.env.NODE_ENV || 'development';
const config = dbConfig[env]
const basename = path.basename(__filename);
const models = {};

let sequelize;
if (config.use_env_variable) {
  sequelize = new Sequelize(process.env[config.use_env_variable], config);
} else {
  sequelize = new Sequelize(config.database, config.username, config.password, config);
}

fs
  .readdirSync(__dirname)
  .filter(file => {
    return (file.indexOf('.') !== 0) && (file !== basename) && (file.slice(-3) === '.js');
  })
  .forEach(async file => {
    const model = await import(path.join('file://', __dirname, file))
    models[model.name] = model;
  });

Object.keys(models).forEach(modelName => {
  if (models[modelName].associate) {
    models[modelName].associate(models);
  }
});

models.sequelize = sequelize;
export default models; 

Hello @umairakram ,

I’m facing the same your issue. Did you have any solution? Please help me

Best Regards