tursodatabase / libsql-client-ts

TypeScript/JavaScript client API for libSQL
https://docs.turso.tech/sdk/ts/quickstart
MIT License
226 stars 32 forks source link

@libsql/client Module parse failed: Unexpected character ' ' (1:1) #184

Open draqo666 opened 7 months ago

draqo666 commented 7 months ago

I’m using this package with NEXT.js and trying to Connect to Turso database. I’m getting this error ` ⨯ ./node_modules/@libsql/darwin-x64/README.md Module parse failed: Unexpected character ' ' (1:1) 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

@libsql/darwin-x64

| | Prebuilt binary package for libsql on darwin-x64.

Import trace for requested module: ./node_modules/@libsql/darwin-x64/README.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 ./src/app/lib/prisma.ts ./src/app/page.tsx `

penberg commented 7 months ago

@draqo666 What version of Next.js is this? The issue is supposed to be fixed in recent versions that have the following bug fix: https://github.com/vercel/next.js/pull/56192

waptik commented 7 months ago

@penberg I'm also facing the same issue in nextjs@14.1.0 and drizzle-orm@^0.29.3. I'm using drizzle queries inside zustand

Error from client(browser):

./node_modules/.pnpm/@libsql+hrana-client@0.5.6/node_modules/@libsql/hrana-client/LICENSE
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 2023 the sqld authors
itsmylife commented 6 months ago

~~I am getting the same problem. I'll keep getting build errors with nextjs@14.1.3, prisma@5.10.2 and libsql@0.5.3, nodejs@20.10.0~~

Failed to compile.

./node_modules/@libsql/darwin-arm64/README.md
Module parse failed: Unexpected character ' ' (1:1)
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
> # `@libsql/darwin-arm64`
| 
| Prebuilt binary package for `libsql` on `darwin-arm64`.
The whole error message ``` > next build ▲ Next.js 14.1.3 - Environments: .env Creating an optimized production build ... Failed to compile. ./node_modules/@libsql/darwin-arm64/README.md Module parse failed: Unexpected character ' ' (1:1) 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 > # `@libsql/darwin-arm64` | | Prebuilt binary package for `libsql` on `darwin-arm64`. Import trace for requested module: ./node_modules/@libsql/darwin-arm64/README.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 ./src/lib/db.ts ./src/actions/contact/save.ts ./node_modules/@libsql/darwin-arm64/index.node Module parse failed: Unexpected character '�' (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 (Source code omitted for this binary file) Import trace for requested module: ./node_modules/@libsql/darwin-arm64/index.node ./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 ./src/lib/db.ts ./src/actions/contact/save.ts ./node_modules/@libsql/hrana-client/LICENSE 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 2023 the sqld authors Import trace for requested module: ./node_modules/@libsql/hrana-client/LICENSE ./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 ./src/lib/db.ts ./src/actions/contact/save.ts ./node_modules/@libsql/hrana-client/README.md Module parse failed: Unexpected character ' ' (1:1) 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 > # Hrana client for TypeScript | | **[API docs][docs] | [Github][github] | [npm][npm]** Import trace for requested module: ./node_modules/@libsql/hrana-client/README.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 ./src/lib/db.ts ./src/actions/contact/save.ts ./node_modules/@libsql/hrana-client/node_modules/node-fetch/LICENSE.md 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 > The MIT License (MIT) | | Copyright (c) 2016 - 2020 Node Fetch Team Import trace for requested module: ./node_modules/@libsql/hrana-client/node_modules/node-fetch/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 ./src/lib/db.ts ./src/actions/contact/save.ts > Build failed because of webpack errors ```

Update

I noticed that I didn't use use server for one of my server components. When I add that the build has succeeded.

Jolg42 commented 6 months ago

I did not try this but I think this could work. Manually add the package to serverComponentsExternalPackages (see https://github.com/vercel/next.js/blob/canary/docs/02-app/02-api-reference/05-next-config-js/serverComponentsExternalPackages.mdx)

itsmylife commented 6 months ago

@Jolg42 While I was trying to share my error message (thank you for being my yellow rubber duck today 😄) I noticed that one of my components is showing up in every time. When I checked it I saw that I forgot to add 🤦 use server on top of it. I added it and now the build is passing.

MustafaWael commented 6 months ago

I faced this issue today, and fixed it with import it with web like that

import {} from "@libsql/client/web"