Zangetsu
Zangetsu2mo ago

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.
npx drizzle-kit push --dialect sqlite --schema ./src/db/schema.ts --url file:./data/db.sqlite
npx drizzle-kit push --dialect sqlite --schema ./src/db/schema.ts --url file:./data/db.sqlite
However, when I try to run it with Deno, i get the fllowing error,
$  deno run -A --node-modules-dir npm:drizzle-kit push --dialect sqlite --schema ./src/db/schema.ts --url file:./data/db.sqlite
LibsqlError: URL_SCHEME_NOT_SUPPORTED: The client that uses Web standard APIs supports only "libsql:", "wss:", "ws:", "https:" and "http:" URLs, got "file:". For more information, please read https://github.com/libsql/libsql-client-ts#supported-urls
$  deno run -A --node-modules-dir npm:drizzle-kit push --dialect sqlite --schema ./src/db/schema.ts --url file:./data/db.sqlite
LibsqlError: URL_SCHEME_NOT_SUPPORTED: The client that uses Web standard APIs supports only "libsql:", "wss:", "ws:", "https:" and "http:" URLs, got "file:". For more information, please read https://github.com/libsql/libsql-client-ts#supported-urls
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
coty
coty2mo ago
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
import { createClient } from "@libsql/client/node"
import { createClient } from "@libsql/client/node"
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 :/
Zangetsu
ZangetsuOP2mo ago
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

Did you find this page helpful?