tursodatabase / libsql-client-ts

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

BUG: Fail to import @libsql/client in node < 18 #210

Open azmy60 opened 1 month ago

azmy60 commented 1 month ago

Hello there!

According to the docs, it's compatible with node version 12 or later. But it seems to fail in node 16 as I ran into an error when importing @libsql/client or @libsql/client/web:

.../node_modules/@libsql/isomorphic-fetch/node.cjs:3
const _Request = Request;
                 ^

ReferenceError: Request is not defined

Upon searching, almost all answers seem to suggest upgrading to node 18.

For now, I can take advantage of using libsql-js instead, but it seems like it doesn't support returning rows in array form https://github.com/tursodatabase/libsql-js/issues/116. Would love to learn to resolve these issues! :)

Note: @libsql/client/sqlite3 works fine, but I feel like it only supports file based or :memory: database?

alcpereira commented 1 month ago

I guess the docs should be updated as node >= 18 is mentioned in the @libsql/isomorphic-fetch (here).

This is a bit weird because the package isomorphic-fetch is generally used for backward compatibility 😅