Mo99 Blog

Quick Error Fix: libsql not parsing it's files within node_modules

August 22, 2024

Next.js with Turso, when building we may run into a parsing error which would be:

Failed to compile.
./node_modules/.pnpm/@libsql+client@0.9.0/node_modules/@libsql/client/README.md
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> <p align="center">
|   <a href="https://docs.turso.tech/sdk/ts/quickstart">
|     <img alt="Turso + TypeScript" src="https://github.com/tursodatabase/libsql-client-ts/assets/950181/5d3a2693-75f9-4c56-9107-8ccaa96785fd" width="1000">

A "band-aid" solution to this is to change your next.config.js to parse the parse the files.

A more permanent solution is to change the way and location which you are instantiating drizzle, see in this GitHub comment.

Change the imports of Drizzle, see in this GitHub comment.

Another fix could be that you are not marking the appropriate files as
use server' discussed here.