libsql-client-ts: Deno example in README.md doesn't work with files
The following fails with Deno:
import { createClient } from "https://esm.sh/@libsql/client@0.4.0-pre.2/node";
const config = {
url: "file:local.db"
};
const db = createClient(config);
const rs = await db.execute("SELECT * FROM users");
console.log(rs);
error: Uncaught Error: module "@libsql/darwin-arm64" not found
at require (https://esm.sh/v135/libsql@0.2.0-pre.2/denonext/libsql.mjs:4:178)
at https://esm.sh/v135/libsql@0.2.0-pre.2/denonext/libsql.mjs:5:1969
at https://esm.sh/v135/libsql@0.2.0-pre.2/denonext/libsql.mjs:5:452
at https://esm.sh/v135/libsql@0.2.0-pre.2/denonext/libsql.mjs:5:4899
this works, however:
import { createClient } from "npm:@libsql/client/node";
const config = {
url: "file:local.db"
};
const db = createClient(config);
const rs = await db.execute("SELECT * FROM users");
console.log(rs);
penberg@vonneumann deno-example % vi example.ts
penberg@vonneumann deno-example % cat example.ts
//import { createClient } from "https://esm.sh/@libsql/client@0.4.0-pre.2/node";
import { createClient } from "npm:@libsql/client/node";
const config = {
url: "file:local.db"
};
const db = createClient(config);
const rs = await db.execute("SELECT * FROM users");
console.log(rs);
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 11
- Comments: 16
I Can confirm this. For me I get the this error:
Using
import { createClient } from "npm:@libsql/client/node";works very wellRemoving the following line:
"deno": "./lib-esm/web.js"from theexportsproperty innode_modules/@libsql/client/package.jsonhas been my most successful workaround so far.EDIT: When using Deno + libsql locally
The following script demonstrates that the import statement
import { createClient } from "@libsql/client/node";is compatible with Deno 2.0.2.The problem remains if you try to compile the app with deno --compile or deploy it to deno deploy.
Same thing happened to me using the Remix vite cloudflare framework and running it with node locally. libsql/client seems to think it’s in the cloudflare environment.