Repository navigation
Open
Labels
pending-approvalBug reports that have not been verified yet, or feature requests that have not been accepted yet
Description
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- Run Simple Sequelize Initialization:
const { Sequelize } = require("sequelize");
const sequelize = new Sequelize("sqlite::memory:");
(async () => {
await sequelize.authenticate();
})();
- 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._Reacted by Lucas Cava
Metadata
Metadata
Assignees
Labels
pending-approvalBug reports that have not been verified yet, or feature requests that have not been accepted yet
Activity
vineetj12 commentedon May 31, 2026
Hi, I've submitted a PR (#18230) that fixes this issue.
Root cause:
uuid >= 9is ESM-only and no longersupports CommonJS
require().Solution: Created a CommonJS-safe wrapper
(
src/utils/uuid.js) with a three-tier fallback:require('uuid')— works for uuid <= 8crypto.randomUUID()— native Node.js fallbackThis 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!
fix(utils): resolve ESM incompatibility with uuid >= 9
knixeur commentedon Jul 24, 2026
Actually [email protected] is CommonJS compatible and solves some security issues.
https://github.com/uuidjs/uuid