Skip to content

Sequelize v6 incompatible with uuid >= 9 due to CommonJS require() usage #18224

Open

Description

@aa-vbana

Issue Creation Checklist

  • I understand that my issue will be automatically closed if I don't fill in the requested information
  • I have read the contribution guidelines

Bug Description

Sequelize v6.x appears to be incompatible with uuid versions >= 9 because Sequelize internally imports uuid using CommonJS syntax:

const uuidv1 = require("uuid").v1;
const uuidv4 = require("uuid").v4;

However, uuid >= 9 is ESM-only and no longer supports require().

This causes runtime failures in Node.js environments using newer uuid versions.

Observed in:

sequelize 6.37.8
uuid 10.x / 14.x
AWS Lambda Node.js runtime

Runtime error:
Error [ERR_REQUIRE_ESM]: require() of ES Module /opt/node_modules/uuid/dist-node/index.js from /opt/node_modules/sequelize/lib/utils.js not supported.
Instead change the require of index.js in /opt/node_modules/sequelize/lib/utils.js to a dynamic import() which is available in all CommonJS modules.

### Reproducible Example
1. Install:
```bash
npm install sequelize@6.37.8 uuid@10
  1. Run Simple Sequelize Initialization:
const { Sequelize } = require("sequelize");

const sequelize = new Sequelize("sqlite::memory:");

(async () => {
  await sequelize.authenticate();
})();
  1. Runtime immediately throws:
    Error [ERR_REQUIRE_ESM]: require() of ES Module uuid/dist-node/index.js from sequelize/lib/utils.js not supported.

Here is the link to the SSCCE for this issue:

What do you expect to happen?

Sequelize should either:

  • support modern ESM-only uuid versions, or
  • avoid direct CommonJS require() usage for uuid imports.

Ideally Sequelize v6 documentation should also clarify compatible uuid versions.

What is actually happening?

Sequelize internally imports uuid using CommonJS require():

const uuidv1 = require("uuid").v1;
This fails with uuid >= 9 because those versions are ESM-only.
Applications crash during initialization with ERR_REQUIRE_ESM.

<!-- Describe what happened. Including relevant details like complete stacktraces & the SQL output -->

### Environment
- Sequelize version: 6.37.8
- Node.js version: 20.x
- Database & Version: PostgreSQL
- Connector library & Version: pg 8.x
- uuid version: 10.x / 14.x
- Runtime: AWS Lambda
- 
<!---
Please answer the questions below. If you don't, your issue will be closed.

To find the version numbers for the three systems below use the following commands:
- `npm list sequelize` / `yarn list --pattern sequelize` (v6 stable)
- `npm list @sequelize/core` / `yarn list --pattern @sequelize/core` (v7 alpha)
- `node -v`
- `npm list typescript` / `yarn list --pattern typescript`
- 'Database' is which actual database system you're using. e.g. 'PostgreSQL 14', 'MariaDB 10.11', etc…
- 'Connector library' is the dependency sequelize requires you to install to interact with a given database type.
  e.g. 'pg' or 'pg-native' for PostgreSQL, 'mysql2' for MySQL, 'tedious' for SQL Server, etc… (see README for complete list).
--->


## Would you be willing to resolve this issue by submitting a Pull Request?
No, I don't have the time, and I understand that I will need to wait until someone from the community or maintainers is interested in resolving my issue.

<!-- Remember that first contributors are welcome! -->

- [ ] Yes, I have the time and I know how to start.
- [ ] Yes, I have the time but I will need guidance.
- [ ] No, I don't have the time, but my company or I are [supporting Sequelize through donations on OpenCollective](https://opencollective.com/sequelize).
- [ X ] No, I don't have the time, and I understand that I will need to wait until someone from the community or maintainers is interested in resolving my issue.

---

<!-- do not delete this footer -->

_Indicate your interest in the resolution of this issue by adding the 👍 reaction. Comments such as "+1" will be removed._

Activity

  1. added theissue type on May 12, 2026
  2. added
    pending-approval
    on May 12, 2026
  3. vineetj12 commented on May 31, 2026

    @vineetj12

    Hi, I've submitted a PR (#18230) that fixes this issue.

    Root cause: uuid >= 9 is ESM-only and no longer
    supports CommonJS require().

    Solution: Created a CommonJS-safe wrapper
    (src/utils/uuid.js) with a three-tier fallback:

    1. require('uuid') — works for uuid <= 8
    2. crypto.randomUUID() — native Node.js fallback
    3. Pure-JS generators — zero dependency fallback

    This avoids making UUID generators async which would
    break Sequelize's public API.

    Tested with: uuid@8, uuid@10, uuid@11, and no uuid
    installed. All unit tests pass
    Would appreciate a review when maintainers get a chance!

  4. added a commit that references this issue on Jun 1, 2026
    344973a
  5. knixeur commented on Jul 24, 2026

    @knixeur

    Actually [email protected] is CommonJS compatible and solves some security issues.

    https://github.com/uuidjs/uuid

    Starting with uuid@12 CommonJS is no longer supported. See implications and uuidjs/uuid#881 for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    pending-approval

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions