I'm using type module/import syntax for the rest of my project, but the Sequelize CLI generates files with require syntax. How should I handle this? I'm already having trouble with not being able to import a file that I renamed to .cjs so sequelize can run it as it uses the require syntax, and I'm sure there will be other issues
-
can you share your package.json file snippet here , what is type used there?aditya rawat– aditya rawat2025-04-22 21:44:07 +00:00Commented Apr 22 at 21:44
Add a comment
|
1 Answer
Try this Simple Solution Different File Types
Re-code files using
importto end with the.mjsextensionRe-code files using
requireto end with the.cjsextensionEach will be handled correctly by Node.js itself.
Or Spend Time Updating Files You Already Have (If You Can Spur the Moment)
Update files generated by Sequelize from this: const Sequelize = require('sequelize'); to this import { Sequelize } from 'sequelize';
I hope my answer would help you