[sequelize] should use commonjs export format, not ES Module
See original GitHub issueSequelize uses commonjs export format. The libdef here uses the ES Module format.
Importing as follows:
const Sequelize = require('sequelize');
Doesn’t work in Flow (though the code runs just fine), you have to import as:
const Sequelize = require('sequelize').default;
Luckily, Sequelize manually added a default
prop to their module.exports
, so the 2nd version works.
However, it’d be better if the types were congruent with the actual export format.
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (10 by maintainers)
Top Results From Across the Web
[ERROR]: require() of ES Module not supported - Stack Overflow
I am not compiling it yet I am using ts-node-dev to run the server but I will put the tsconfig.json in the question...
Read more >CommonJS vs. ES modules in Node.js - LogRocket Blog
Learn about the differences between CommonJS and ES modules when using them in Node.js applications to organize software code.
Read more >Models Definition - Sequelize
sequelize.import can only load CommonJS files, and is not capable of loading ecmascript modules . Use native import if you need to load ......
Read more >Upgrade your Node app: From CommonJS to ES Modules
1) Prepare your code · 2) Update the package.json · 3) Convert all imports and exports · 4) Fix imports and exports ·...
Read more >ES Modules in Node.js - Maxim Orlov
My notes on the ES Modules in Node.js presentation by Gil Tayar at Nodeconf ... Importing and exporting a module in Common JS...
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 FreeTop 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
Top GitHub Comments
I was mistaken and eventually found a solution
@zeorin another reason I think using ES module declarations is a better tradeoff – since a transpiler is required to strip flow type annotations (unless you put annotations in comments), most devs are probably already able to use
import
statements, and probably prefer to since they look better next toimport type
statements, and they can mix inimport Sequelize, {type FindOptions} from 'sequelize'
.