I was switching my database from planetscale to turso but I'm getting the following error
{
"errorType": "Runtime.ImportModuleError",
"errorMessage": "Error: Cannot find module '@libsql/linux-x64-gnu'\nRequire stack:\n- /var/task/index.js\n- /var/runtime/index.mjs",
"trace": [
"Runtime.ImportModuleError: Error: Cannot find module '@libsql/linux-x64-gnu'",
"Require stack:",
"- /var/task/index.js",
"- /var/runtime/index.mjs",
" at _loadUserApp (file:///var/runtime/index.mjs:1061:17)",
" at async UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1093:21)",
" at async start (file:///var/runtime/index.mjs:1256:23)",
" at async file:///var/runtime/index.mjs:1262:1"
]
}
I use the aws cdk to build and deploy my aws lambda function internally it uses esbuild here is a simple reproduction step
the aws lambda function code
/nodejs/index.ts
import { drizzle } from 'drizzle-orm/libsql';
import { createClient } from '@libsql/client';
const client = createClient({ url: 'DATABASE_URL', authToken: 'DATABASE_AUTH_TOKEN' });
const db = drizzle(client);
export const handler = async (event) => {
console.log('event', event);
}
the aws cdk code to deploy the function:
import {Construct} from 'constructs';
import {NodejsFunction} from 'aws-cdk-lib/aws-lambda-nodejs';
import {Architecture, Runtime} from 'aws-cdk-lib/aws-lambda';
export class SendUserToDynamo extends Construct {
function: NodejsFunction;
constructor(scope: Construct, id: string) {
super(scope, id);
// lambda function that triggers on aws lambda user created event
this.function = new NodejsFunction(this, 'sendUserToDynamo', {
entry: __dirname + '/nodejs/index.ts',
handler: 'handler',
architecture: Architecture.X86_64,
runtime: Runtime.NODEJS_18_X,
});
}
}
Everything works when I'm using the PlanetScale driver, so the error must come from libsql and not the CDK build step. I tried using a Dockerfile without TypeScript and ESBuild, and it did work
I was switching my database from planetscale to turso but I'm getting the following error
I use the aws cdk to build and deploy my aws lambda function internally it uses esbuild here is a simple reproduction step
the aws lambda function code
/nodejs/index.ts
the aws cdk code to deploy the function:
Everything works when I'm using the PlanetScale driver, so the error must come from libsql and not the CDK build step. I tried using a Dockerfile without TypeScript and ESBuild, and it did work