Can't resolve `zod/v4/core`
Version Number
5.2.0
Codesandbox/Expo snack
N/A
Steps to reproduce
Getting this error in both development and build:
Module not found: Can't resolve 'zod/v4/core'
Module not found: Can't resolve 'zod/v4/core'
> 1 | import{validateFieldsNatively as r,toNestErrors as e}from"@hookform/resolvers";import{appendErrors as o}from"react-hook-form";import*as n from"zod/v4/core";function t(r,e){try{var o=r()}catch(r){return e(r)}return o&&o.then?o.then(void 0,e):o}function s(r,e){for(var n={};r.length;){var t=r[0],s=t.code,i=t.message,a=t.path.join(".");if(!n[a])if("unionErrors"in t){var u=t.unionErrors[0].errors[0];n[a]={message:u.message,type:u.code}}else n[a]={message:i,type:s};if("unionErrors"in t&&t.unionErrors.forEach(function(e){return e.errors.forEach(function(e){return r.push(e)})}),e){var c=n[a].types,f=c&&c[t.code];n[a]=o(a,e,n,s,f?[].concat(f,t.message):t.message)}r.shift()}return n}function i(r,e){for(var n={};r.length;){var t=r[0],s=t.code,i=t.message,a=t.path.join(".");if(!n[a])if("invalid_union"===t.code){var u=t.errors[0][0];n[a]={message:u.message,type:u.code}}else n[a]={message:i,type:s};if("invalid_union"===t.code&&t.errors.forEach(function(e){return e.forEach(function(e){return r.push(e)})}),e){var c=n[a].types,f=c&&c[t.code];n[a]=o(a,e,n,s,f?[].concat(f,t.message):t.message)}r.shift()}return n}function a(o,a,u){if(void 0===u&&(u={}),function(r){return"_def"in r&&"object"==typeof r._def&&"typeName"in r._def}(o))return function(n,i,c){try{return Promise.resolve(t(function(){return Promise.resolve(o["sync"===u.mode?"parse":"parseAsync"](n,a)).then(function(e){return c.shouldUseNativeValidation&&r({},c),{errors:{},values:u.raw?Object.assign({},n):e}})},function(r){if(function(r){return Array.isArray(null==r?void 0:r.issues)}(r))return{values:{},errors:e(s(r.errors,!c.shouldUseNativeValidation&&"all"===c.criteriaMode),c)};throw r}))}catch(r){return Promise.reject(r)}};if(function(r){return"_zod"in r&&"object"==typeof r._zod}(o))return function(s,c,f){try{return Promise.resolve(t(function(){return Promise.resolve(("sync"===u.mode?n.parse:n.parseAsync)(o,s,a)).then(function(e){return f.shouldUseNativeValidation&&r({},f),{errors:{},values:u.raw?Object.assign({},s):e}})},function(r){if(function(r){return r instanceof n.$ZodError}(r))return{values:{},errors:e(i(r.issues,!f.shouldUseNativeValidation&&"all"===f.criteriaMode),f)};throw r}))}catch(r){return Promise.reject(r)}};throw new Error("Invalid input: not a Zod schema")}export{a as zodResolver};
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 | //# sourceMappingURL=zod.module.js.map
3 |
Package versions:
- "zod": "^4.1.11"
- "@hookform/resolvers": "^5.2.0",
Expected behaviour
Package should be able to resolve zod v4 properly
What browsers are you seeing the problem on?
No response
Relevant log output
Code of Conduct
- [x] I agree to follow this project's Code of Conduct
Had to add this to my .pnpmfile.cjs to override the transitive deps. You can't import zod if its not in your dependencies! Believe it or not this is the second time I am encountering this problem. PR here: https://github.com/react-hook-form/resolvers/pull/765
function readPackage(pkg) {
if (pkg.name === "@hookform/resolvers") {
pkg.dependencies = {
...pkg.dependencies,
zod: "^4.0.0",
};
}
return pkg;
}
module.exports = {
hooks: {
readPackage,
},
};
This randomly became an issue for me when everything was working fine before? The .pnpmfile hack didn't work for me :(
I'm also having issues randomly 😓 It was working right before I did an update. The .pnpmfile also didn't work for me.
Edit: I am so confused, turns out the pnpm hack did work 😖 but it broke again LOL
The same issue occurs in Yarn PnP. I tested this with zod 4.1.13 and @hookform/resolvers 5.2.2.
Cannot find module 'zod/v4/core' from ....