Error importing @planetscale/database
I am trying to setup my drizzle orm, but I am having an issue with the "@planetscale/database" module. Heres the error message:
This happens when I run the following in my vercel serverless function
in both production and dev mode:
Following the setups outlined here: https://orm.drizzle.team/docs/installation-and-db-connection/mysql/planetscale
I tried to switch the import to a dynamic one but had issues related to importing in other modules as I had to then change my tsconfig settings.
Here is a stack overflow post by another person describing the same issue in nearly the same way: https://stackoverflow.com/questions/76424056/planetscale-database-produces-an-error-with-drizzle-in-hapi-with-ts-node-in
Please help I have spent a few hours looking for solutions and have no idea how to fix it. Also if anyone has any reading recommendations on the intricacies on nodes module system please let me know!
PlanetScale – DrizzleORM
Drizzle ORM | %s
Stack Overflow
@planetscale/database produces an error with drizzle (in Hapi, with...
I am using Drizzle ORM and Planetscale.
Connecting to Planetscale I get an error:
Error [ERR_REQUIRE_ESM]: require() of ES Module /node_modules/@planetscale/database/dist/index.js from src/database/
1 Reply
I did more testing without drizzle in the same project directory with the following code:
Based on code from: https://github.com/planetscale/database-js
But got the same error. Therefore it seems like it's purely an issue with the way I am using the @planetscale/database module. I think it might be an issue with my tsconfig target. Does this seem like a likely culprit? Any recommendations on fixes or where I may be able to find fixes?
GitHub
GitHub - planetscale/database-js: A Fetch API-compatible PlanetScal...
A Fetch API-compatible PlanetScale database driver - GitHub - planetscale/database-js: A Fetch API-compatible PlanetScale database driver