Cannot find module 'zod/v4' or its corresponding type declarations.
I have seen the solution is to update the module and moduleResolution entries in the tsconfig. However, this isn't ideal as it breaks other things in our projects.
This is particularly frustrating as we had already done a lot of work to migrate to zod4 when it was on the "next" branch. But now that it's been officially released, we have to keep using v3 but with the "zod/v4" import, which breaks types.
Can we just have a 4.0.0 release? Would remove the requirement to change tsconfig.json, making migration so much easier.
We are also having issues with the build. Initially using the v3.25.7 we had the same errors trying to use zod/v4. Now I updated to v3.25.20 and our vite build will not compile. I will investigate and see if we can get some more information but theres defintely something problematic with the /v4 and typescript that is no longer working. (It was working with the ...beta... version)
TS2307: Cannot find module zod/v4 or its corresponding type declarations.
We cannot change our module/moduleResolutions either. I guess we're stuck on the 4.0.0 beta.
I think a valid solution is the following addition to your tsconfig file:
"paths": {
/* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
"zod/v4": ["./node_modules/zod/dist/types/v4/index.d.ts"],
"zod/v4/core": ["./node_modules/zod/dist/types/v4/core/index.d.ts"]
},
Note: One might not need the v4/core path. I just pasted it from my setup since I needed it.
That way the module resolution is not changed and everything works as it is supposed to.
Unfortunately, that doesn't work. Now it throws this error.
✘ [ERROR] Could not resolve "./classic/index.js"
node_modules/zod/dist/types/v4/index.d.ts:1:15:
1 │ import z4 from "./classic/index.js";
~~What tsconfig are expected for this to work? I am encountering this issue and my tsconfig seems to be as per the requirements~~
Updated to latest version and seems to be working
I tried it and I no longer get this error 🎉!
But, now there's a new error: https://github.com/colinhacks/zod/issues/4615
still go this with monorepo and install zod in the root with pnpm
Long fixed at this point
Still an issue actually
still go this with monorepo and install zod in the root with pnpm
This helps ty