I am trying to setup my drizzle orm, but I am having an issue with the "@planetscale/database" module. Heres the error message:
Error: require() of ES Module C:\<PATH>\node_modules\@planetscale\database\dist\index.js from C:\<PATH>\db\connect.ts not supported.Instead change the require of index.js in C:\<PATH>\db\connect.ts to a dynamic import() which is available in all CommonJS modules.
Error: require() of ES Module C:\<PATH>\node_modules\@planetscale\database\dist\index.js from C:\<PATH>\db\connect.ts not supported.Instead change the require of index.js in C:\<PATH>\db\connect.ts to a dynamic import() which is available in all CommonJS modules.
This happens when I run the following in my vercel serverless function in both production and dev mode:
import 'dotenv/config'import { connect } from "@planetscale/database";import { drizzle } from "drizzle-orm/planetscale-serverless";const conn = connect({ host: process.env.DB_HOST!, username: process.env.DB_USERNAME!, password: process.env.DB_PASSWORD!,});export const db = drizzle(conn);
import 'dotenv/config'import { connect } from "@planetscale/database";import { drizzle } from "drizzle-orm/planetscale-serverless";const conn = connect({ host: process.env.DB_HOST!, username: process.env.DB_USERNAME!, password: process.env.DB_PASSWORD!,});export const db = drizzle(conn);
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!
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/