Closed CodingDoug closed 1 year ago
It is unclear how we could do this, because we have very little control about errors during imports.
Also, the client has been rewritten significantly since this issue was created, so perhaps the problem is no longer so acute? For example, I used a wrong import a few days ago, and I received a quite understandable error message saying that it's not possible to require("fs")
.
Doug, feel free to reopen if this is still a problem :)
When someone unknowingly uses @libsql/client in an environment where nodejs APIs are not available, such as a browser, they get a mostly unhelpful error:
This is a side-effect of eagerly importing better-sqlite3 which depends on node API. It would be better if we can detect this scenario at runtime before importing it, then produce a more helpful error message telling the developer to use @libsql/client/http instead.