Replies: 4 comments 2 replies
|
Hi 👋 The issue is with the import path.
You need to install: bun add @drizzle-orm/zod (or npm / pnpm equivalent) Then import like this: import { createSelectSchema } from "@drizzle-orm/zod"; Not: import { createSelectSchema } from "drizzle-orm/zod"; That’s why you're seeing: Cannot find module 'drizzle-orm/zod' After installing the correct package, it should work as expected 👍 Let me know if this resolves your issue. If it does, feel free to mark this as the accepted answer so others running into the same migration confusion can find it easily. |
|
There are two packages and they serve different purposes — here's the current state:
|
|
The confusion comes from the docs showing v1 syntax while you're on v0.x. On stable (0.45.x): bun add drizzle-zod zodimport { createSelectSchema, createInsertSchema } from 'drizzle-zod'
import { users } from './schema'
const selectUserSchema = createSelectSchema(users)
const insertUserSchema = createInsertSchema(users)
// You can also refine fields:
const insertUserSchema = createInsertSchema(users, {
email: (schema) => schema.email.email(),
name: (schema) => schema.name.min(1),
})On v1 beta (1.0.0-beta.2+): The validators were moved into the core package. If you want to use the new import path now: bun add drizzle-orm@betaimport { createSelectSchema, createInsertSchema } from 'drizzle-orm/zod'This is documented in the v1 beta.2 release notes:
TL;DR: If you're on stable, use |
|
Yeah, drizzle-orm/zod is the v1 path on 0.45.x it doesn't exist yet (no ./zod export in the package) so that import just can't On stable you want the separate drizzle-zod package: bun add drizzle-zod const insertUser = createInsertSchema(users); If you're on zod 4, make sure drizzle-zod is 0.8.3 or newer that's the first one that allows zod 4 in its peers (^3.25.0 || The drizzle-orm/zod import only lands once you're on the v1 beta, so unless you're moving to that, just stay on drizzle-zod |
Uh oh!
There was an error while loading. Please reload this page.
the documentation says that
drizzle-zodis getting deprecated for v1 in favor ofdrizzle-orm/zod. When I try toimport { createSelectSchema } from 'drizzle-orm/zod';as the documentation says I get an error saying "Cannot find module drizzle-orm/zod or its corresponding type declarations. (ts 2307)". I am using"drizzle-orm": "^0.45.1",which is very current if not the latest version I get when usingbun add. Any idea on how to do this?All reactions