models/index.js doesn't work with ES6 modules
See original GitHub issueWhat you are doing?
Trying to load models with models/index.js doesn’t work with ES6 modules activated with "type": "module"
const basename = path.basename(__filename);
// {...}
const model = require(path.join(__dirname, file))(sequelize, Sequelize.DataTypes);
Variables like __filename
and __dirname
don’t work anymore with modules.
What do you expect to happen?
There should be an option to choose between Modules or CommonJS.
What is actually happening?
There’s only CommonJS support.
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (4 by maintainers)
Top Results From Across the Web
Problems using "index.js" to import ES6 JS Modules
I'm working with React Native and using index.js to manage modules. I have many projects consuming from the same components folder, ...
Read more >Sequelize model loading with ES6 - Ismayil Khayredinov
A restrospect into defining and loading sequelize models using config objects and ES6 classes.
Read more >How to use an ES6 import in Node.js?
Node js doesn't support ES6 import directly. If we try to use import for importing modules directly in node js it will throw...
Read more >JavaScript modules - MDN Web Docs
This guide gives you all you need to get started with JavaScript module syntax. A background on modules. JavaScript programs started off pretty ......
Read more >A Practical guide to ES6 modules
And then just load app.js script in our index.html . But first, in order to make it work, we need to use type="module"...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is my solution for the moment
model.default …error saying TypeError: model.default is not a function please help