Getting error while using Drizzle with MySQL2

I am following this guide: https://orm.drizzle.team/docs/get-started-mysql#mysql-2

My setup:
Using below code for drizze:
const config: ConnectionOptions = {
  host: process.env.DB_HOST!,
  user: process.env.DB_USERNAME!,
  password: process.env.DB_PASSWORD!,
};
const connection = await mysql.createConnection(config);

export const db = drizzle(connection, { schema: schema, mode: "default" });


Getting below error:
⨯ ../../node_modules/.pnpm/mysql2@3.9.1/node_modules/mysql2/lib/auth_plugins/caching_sha2_password.js:6:15
Module not found: Can't resolve 'crypto'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
../../node_modules/.pnpm/mysql2@3.9.1/node_modules/mysql2/lib/auth_plugins/index.js
../../node_modules/.pnpm/mysql2@3.9.1/node_modules/mysql2/index.js
../../node_modules/.pnpm/mysql2@3.9.1/node_modules/mysql2/promise.js
../../packages/db/src/index.ts
../../packages/auth/src/index.ts
./src/app/api/trpc/[trpc]/route.ts
GitHub
Clean and simple starter repo using the T3 Stack along with Expo React Native - GitHub - t3-oss/create-t3-turbo: Clean and simple starter repo using the T3 Stack along with Expo React Native
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Was this page helpful?