question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[sequelize] should use commonjs export format, not ES Module

See original GitHub issue

Sequelize 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:closed
  • Created 4 years ago
  • Comments:11 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
retyuicommented, Apr 26, 2019

I was mistaken and eventually found a solution

0reactions
jedwards1211commented, May 7, 2019

@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 to import type statements, and they can mix in import Sequelize, {type FindOptions} from 'sequelize'.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found