New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error [ERR_REQUIRE_ESM] #1660
Comments
If you use ESM, you can't set a path as the value for the import { AddressListEntry } from './address-list-entry.js';
const sequelize = new Sequelize({
dialect: DB_ENGINE as Dialect,
storage: DB_STORE,
logging: (msg) => logger.debug(msg),
models: [AddressListEntry],
}); We can't use Sequelize 7 provides a new utility called |
Thank you for the quick response. |
If you want you can also copy the Sequelize 7 I'll move this issue to the sequelize-typescript repo as for Sequelize 6, that's where I'd expect to add this feature |
const models = Object.entries(allModels).map(([_, model]) => model) export default sequelize It's my structure. |
Issue Creation Checklist
Bug Description
I get this error at runtime "Error [ERR_REQUIRE_ESM] require() of ES Module redacted/dist/src/data/models/AddressListEntry.js from redacted/node_modules/sequelize-typescript/dist/sequelize/sequelize/sequelize-service.js not supported.
Instead change the require of AddressListEntry.js in redacted/node_modules/sequelize-typescript/dist/sequelize/sequelize/sequelize-service.js to a dynamic import() which is available in all CommonJS modules."
I just started this application, so it contains very little code, and all done exactly to what is suggested in the documentation. My models are trivial at this point, as I am just trying to get the tools configured and working before building out the functionality.
I am using:
Node 18.12.1
sequelize 6.31.1
sequelize-typescript 2.1.5
sqlite 3 5.1.6
In my tsconfig.json I have:
I am creating the database instance like this:
My models folder only contains 3 models so far, and they are all very basic. The
AddressListEntry
model mentioned in the error message is:Reproducible Example
I don't think I can use the SSCCE to reproduce this problem since it is related to module loading.
The relevant bits of code are in the description above. If there are additional files that I didn't include, please let me know and I will update the ticket.
What do you expect to happen?
The program should run without errors
What is actually happening?
The process exits with an error message:
"Error [ERR_REQUIRE_ESM] require() of ES Module redacted/dist/src/data/models/AddressListEntry.js from redacted/node_modules/sequelize-typescript/dist/sequelize/sequelize/sequelize-service.js not supported.
Instead change the require of AddressListEntry.js in redacted/node_modules/sequelize-typescript/dist/sequelize/sequelize/sequelize-service.js to a dynamic import() which is available in all CommonJS modules."
Environment
Would you be willing to resolve this issue by submitting a Pull Request?
Indicate your interest in the resolution of this issue by adding the 👍 reaction. Comments such as "+1" will be removed.
The text was updated successfully, but these errors were encountered: