Error: Cannot find module '@libsql/darwin-arm64' when using Drizzle/SST

I'm using SST in a monorepo with Drizzle, and my Drizzle setup is in a separate workspace package. When I try calling code that invokes the Drizzle client I get this error about missing a platform specific module:
backend:dev: | Invoked src/endpoints/domains.handler
backend:dev: | Built src/endpoints/domains.handler
backend:dev: | Error: Cannot find module '@libsql/darwin-arm64'
backend:dev: Require stack:
backend:dev: - /Users/joostschuur/Code/Playmob/survey-dashboard/apps/backend/.sst/artifacts/c8a74ec35862a7b85e0a79e5a246c48c9f0b665e9b/src/endpoints/domains.mjs
backend:dev: Error: Cannot find module '@libsql/darwin-arm64'
backend:dev: Require stack:
backend:dev: - /Users/joostschuur/Code/Playmob/survey-dashboard/apps/backend/.sst/artifacts/c8a74ec35862a7b85e0a79e5a246c48c9f0b665e9b/src/endpoints/domains.mjs
backend:dev: | Invoked src/endpoints/domains.handler
backend:dev: | Built src/endpoints/domains.handler
backend:dev: | Error: Cannot find module '@libsql/darwin-arm64'
backend:dev: Require stack:
backend:dev: - /Users/joostschuur/Code/Playmob/survey-dashboard/apps/backend/.sst/artifacts/c8a74ec35862a7b85e0a79e5a246c48c9f0b665e9b/src/endpoints/domains.mjs
backend:dev: Error: Cannot find module '@libsql/darwin-arm64'
backend:dev: Require stack:
backend:dev: - /Users/joostschuur/Code/Playmob/survey-dashboard/apps/backend/.sst/artifacts/c8a74ec35862a7b85e0a79e5a246c48c9f0b665e9b/src/endpoints/domains.mjs
This from this API handler in apps/backend:
import { ApiHandler } from 'sst/node/api';

import { db, domains } from 'database';

export const handler = ApiHandler(async () => {
const res = await db.select().from(domains);

return {
statusCode: 200,
body: JSON.stringify(res, null, 2),
};
});
import { ApiHandler } from 'sst/node/api';

import { db, domains } from 'database';

export const handler = ApiHandler(async () => {
const res = await db.select().from(domains);

return {
statusCode: 200,
body: JSON.stringify(res, null, 2),
};
});
With db being exported from packages/database here:
import { createClient } from '@libsql/client';
import { drizzle } from 'drizzle-orm/libsql';

import * as schema from '@/schema';

const authToken = process.env.DATABASE_AUTH_TOKEN;
const url = process.env.DATABASE_URL;

const client = createClient({
url,
authToken,
});

export const db = drizzle(client, { schema });
import { createClient } from '@libsql/client';
import { drizzle } from 'drizzle-orm/libsql';

import * as schema from '@/schema';

const authToken = process.env.DATABASE_AUTH_TOKEN;
const url = process.env.DATABASE_URL;

const client = createClient({
url,
authToken,
});

export const db = drizzle(client, { schema });
packages/database has @libsql/client as a dependency, nothing platform specific. If I explicitly add @libsql/darwin-arm64 as a dependency to apps/backend, then that works for local dev. When I deploy it, it complains about @libsql/linux-x64-gnu of course, but this should just work without a hack like that, right? I have a Next.js app running on Vercel (for now) also importing the database package and that works just fine.
2 Replies
joostschuur
joostschuurOP10mo ago
This also seems to happen without using a monorepo, when I have drizzle setup and schema files locally and all the right dependencies installed.
joostschuur
joostschuurOP10mo ago
Looks like it's an issue with recent versions of @libsql/client per https://github.com/tursodatabase/libsql-client-ts/issues/112 I downgraded to @libsql/client 0.3.3 and it worked.
GitHub
"Runtime.ImportModuleError: Error: Cannot find module '@libsql/linu...
I was switching my database from planetscale to turso but I'm getting the following error { "errorType": "Runtime.ImportModuleError", "errorMessage": "Error: ...
Want results from more Discord servers?
Add your server