resolvers: Uncaught ReferenceError: exports is not defined
trying to:
import { zodResolver } from "@hookform/resolvers/zod";
gives me:
Uncaught ReferenceError: exports is not defined
at Module../node_modules/@hookform/resolvers/dist/zod.js (zod.js:11)
at __webpack_require__ (bootstrap:789)
at fn (bootstrap:100)
at Object../node_modules/@hookform/resolvers/zod.js (zod.js:1)
at __webpack_require__ (bootstrap:789)
at fn (bootstrap:100)
...
This is a Rails webpacker + typescript app.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 52 (17 by maintainers)
Commits related to this issue
- Upgraded to hookform-resolvers beta - Fixes issue: - https://github.com/react-hook-form/resolvers/issues/71#issuecomment-754623998 — committed to Jacobjeevan/Link-Shortener by Jacobjeevan 3 years ago
@amankkg I’m glad it solves your problem ! 😃 But
1.4.0-beta.1
was a mistake with semantic-release. Please use2.0.0-beta.3
instead.Next.js’s users have the same problem since 1.3.1 : #100 Workaround possible: use the v1.3.0 or try the v2 beta
EDIT (2/1/2020): Same for Snowpack users
For everyone which want to try the v2, you can install the
@hookform/resolvers@beta
, at this time thebeta.3
contains:Feedbacks are really appreciated 😃 If some of you get some errors with modules, please reply here.
👋🏻 You can try the last version v1.3.6. The issue should be solved
No, we don’t. It’s open-source, we are all working on this in our free time. So no pressure, we get it right and we ship it out. I am planning to do a quick video to cover some of the major changes and improvements, then we can release a beta version and get more users to “test” this out.
I am getting this too for yup on a non-rails project. I am only getting the error on production build and not in development build.
Edit: after adding
sourceType: 'unambiguous'
intobabel.config.js
, I am able to resolve the runtime error. The issue might be https://github.com/webpack/webpack/issues/4039#issuecomment-419284940.I was having this issue with yup and nextjs. After downgrading to 1.3.0, everything seems to be working OK. Thanks for the workaround @jorisre
@hamzahasbi It works well for me, thanks.
@asotog At the same time of react-hook-form v7
@bluebill1049 Do we have a “deadline” ?
using “@hookform/resolvers”: “2.0.0-beta.3” with “next”: “10.0.7” seems to work perfectly! Thanks !
@borivojevic Happy to try Snowpack, esbuild is fast as expected 🚀
In your example you use the version 1.3.3 which have an issue with module exports (solved in v2). In your case, I recommend to use the 1.3.0 or try the v2 beta. I get your example working with these both versions.
I added a note for Snowpack users : https://github.com/react-hook-form/resolvers/issues/71#issuecomment-754623998
Hope it helps
@jorisre I hope this example helps.
yarn install && yarn start
should result in error.This is the implementation that’s problematic.
It seems to work for @tajdien, can you share a working example please ?
@borivojevic I’m not familiar with Snowpack but if you have a reproductible example to provide then I can investigate thanks !
Another workaround that works with snowpack v3.0.11 would be:
I had the same issue with 1.3.2 using snowpack. 2.0.0-beta.3 didn’t work either.
Although snowpack suggests this workaround that seems to be working for me:
I’m facing the same issue as https://github.com/react-hook-form/resolvers/issues/100 ,
Now, I can’t deploy to vercel 😦
The versions I’m using are:
I had this lightbulb moment too 😃 But unfortunately that solution alone didn’t help. Thanks anyway John.
Having the same issue, also using rails/webpacker. Downgrading to 0.1.1 did resolve.
^1.3.0
will install the latest version>=1.3.0 <2.0.0
. If you want to pin a specific version you should remove the caret^
.For me too !! 😄
Thanks @jorisre. I can confirm that v2 beta works on this smaller example as well.
@MontoyaAndres try to use the latest beta version.
I had the same issue with
1.3.2
using snowpack. Upgrading it to2.0.0-beta.3
resolved the issue for me aswell.@jorisre it is quite messy 😅 let me know if you need clear and stable reproduction repo
@jorisre hmm on 1.3.0 it works properly
here is my WIP https://github.com/amankkg/frontend-template
Hi all, the last version 1.3.1 should fix this issue, someone can confirm ? Thanks
Thanks for reporting, I’m looking for a solution
@batamire Hi 👋🏻
Does that error occur at build time ?
Can you provide more informations please ? Your code snippets doesn’t help me 😕