Module parse failed: Unexpected token
I have tried to use @libsql/client together with drizzle inside some new projects of mine, however I always get the following error, whatever I try.
Module parse failed: Unexpected token (1:4)
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
> MIT License
|
| Copyright (c) 2023 libSQL
Import trace for requested module:
./node_modules/@libsql/client/LICENSE.md
./node_modules/@libsql/ ./node_modules/@libsql/ sync ^\.\/.*$
./node_modules/libsql/index.js
./node_modules/@libsql/client/lib-esm/sqlite3.js
./node_modules/@libsql/client/lib-esm/node.js
At first I though the problem was using bun, but this also happens every time with npm and pnpm.
Rest of my project setup:
- Next.js 13.5 / 14.0.1
- bun 1.0.5
- @libsql/client 0.3.6 (also tried 0.3.7-pre.2 to no success)
Usage of @libsql/client:
import { createClient } from "@libsql/client";
import { drizzle } from "drizzle-orm/libsql";
const connection = createClient({
url: process.env.DATABASE_URL || "",
authToken: process.env.DATABASE_AUTH_TOKEN,
});
Thank you!
It seems like I encountered the same error message because I accidentally called libsql from a client component. It might be helpful to double-check that. Additionally, this error message was observed when using Next.js version < 13.5.5. In such cases, you need to modify the Next.js config. You can find more information on how to do this here: https://github.com/libsql/libsql-client-ts#using-the-library-with-nextjs .