Creating migrations while using ES Modules fails with error `Cannot find module '<filename>.js`
Recently I upgraded our CommonJS project to use the modern standard of ES Modules. However, it appears that Drizzle kit either straight up does not support the use of ES Modules, or I have forgotton to add some new configuration after the move. Either way, migrations stopped working after adding the required
.js
file extension when using ESM explicitly when importing Typescript source files.
Any help would be much appreciated as this is a huge show stopper for us.
Pretty much this exact issue.
https://github.com/drizzle-team/drizzle-orm/issues/781#issuecomment-1636323759GitHub
[BUG]:Drizzle-Kit 0.19.0 Fails to Generate Migrations · Issue #781 ...
What version of drizzle-orm are you using? 0.27.0 What version of drizzle-kit are you using? 0.19.0 Describe the Bug I was using Drizzle Kit version of 0.18.1 and generating migrations with this co...
2 Replies
Ended up finally finding a work-around here:
https://github.com/drizzle-team/drizzle-kit-mirror/issues/55#issuecomment-1808473568
GitHub
Typescript and ESM not working together · Issue #55 · drizzle-team/...
Hi, On a project using typescript and ESM mode, it seems that drizzle-kit generate doesn't resolve imports properly. For example, with such a layout: | - schemas -- table1.ts -- table2.ts If ...
Not sure if you fixed, but double check your
moduleResolution
as that was what got me with this issue. Solved by using NodeNext
or Node
instead of ESNext
, ES2021
etc...