Running drizzle-kit for local SQLite databases with Deno
I have been going through old issues in the Deno and libSQL to check this specific problem.
Mainly,
- https://github.com/drizzle-team/drizzle-orm/discussions/3162
- https://github.com/denoland/deno/issues/19826
Provided solutions in both cases do not seem to be working for me.
This is my current setup,
- I have
"nodeModulesDir": "auto",
set in my deno.json
.
- Schema is in ./src/db/schema.ts
, drizzle config is in ./drizzle.config.ts
, and the database is supposed to be in ./data/db.sqlite
.
I can run the following command with npx or bun and it works just fine.
However, when I try to run it with Deno, i get the fllowing error,
I really like how Deno handles my project. Is there some way I can get this to work with Deno and avoid using npx or node?2 Replies
The easy fix is to import the node client. It’s not a deno issue but a libsql issue and I don’t know why they refuse to fix it, it’s been like this for a long time with a ton of complaints
Actually I forgot about drizzlekit issues I’m sorry, you might have to import the functions from
drizzle-orm/libsql
in a script and execute them instead of using drizzle kit cli
You might be able to do this actually, I’ll try later
https://docs.deno.com/runtime/fundamentals/node/#conditional-exports
edit: --conditions node
doesn't work :/Yeah. This has been extremely painful. The issue is not with libsql in this case drizzle kit should import the node module I think
maybe they have a good reason for not doing that