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
Angelelz
Angelelz15mo ago
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
Angelelz
Angelelz15mo ago
npm i drizzle-orm mysql2
npm i -D drizzle-kit
npm i drizzle-orm mysql2
npm i -D drizzle-kit
It's all in the installation instructions for each driver
azure199
azure199OP15mo ago
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.
azure199
azure199OP15mo ago
Yes, mysql2 from the docs is what I have selected as my driver
Angelelz
Angelelz15mo ago
Depends on your environment and connection
azure199
azure199OP15mo ago
Which file would that be in to share?
Angelelz
Angelelz15mo ago
I don't understand the question
azure199
azure199OP15mo ago
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.
Want results from more Discord servers?
Add your server