Cannot find driver! mysql2 or pg.
I'm trying to run drizzle-kit studio can get this error:
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'mysql2' imported from C:\Users\rober\code\projects\drizsup\node_modules\drizzle-orm\mysql2\index.mjs
Here is my drizzle.config.ts:
import type { Config } from "drizzle-kit";
export default {
schema: "./src/lib/schema.ts",
out: "./src/lib/db",
driver: "mysql2",
dbCredentials: {
connectionString: process.env.DATABASE_URL,
},
} satisfies Config;
If I remove the driver option it says no driver option found, if I add driver: mysql2 or pg it says cannot find driver mysql2 or pg? Looked through other help questions couldn't find a solution.
10 Replies
mysql2 or pg must be installed.
You have to pick what driver you'll be using, depending on your provider or where you're hosting your db
If you're using mysql2: https://orm.drizzle.team/docs/installation-and-db-connection/mysql/mysql2
Node MySQL 2 – DrizzleORM
Drizzle ORM | %s
It's all in the installation instructions for each driver
Is this different from the drizzle docs for planetscale?
npm i drizzle-orm @planetscale/database
npm i -D drizzle-kit
Maybe a better question is which driver does planetscale use? I thought it would be mysql2.Yes, mysql2 from the docs is what I have selected as my driver
Depends on your environment and connection
Which file would that be in to share?
I don't understand the question
I apologize. I got it working. I just didn't clearly see that you need to run both
npm i drizzle-orm @planetscale/database and npm i drizzle-orm mysql2
. I assumed the planetscale and kit install would have everything required. Sorry for the trouble. It's easy to overpass in docs.