-
-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NextJs 12: Named export set
not found
#271
Comments
@mrodrigues95 |
@allwd That seems to work as a work around for the time being, thanks. |
I'm facing this bug as well after updating to Nextjs 12.0.2, and I did not encounter this issue on Nextjs 12.0.1 |
Having the same issue with NextJS 12.0.2, the temporary fix provided by @allwd works. |
How about Typescript? I tried @allwd 's suggestion, but it doesn't work well.
|
Hi @sgonv. For Typescript, you need to import resolver like |
Hey all 👋🏻 |
thanks @jorisre 🙏 |
@azarmehri Oh, it worked for me. Thanks! |
Having the same issue with NextJS 12.0.2;
This is a way to bypass the Rust compiler and does not solve the fundamental problem. If you install a dependency that does not satisfy the CommonJS module, the project will still not run properly |
I'm having the same issue and @allwd solution worked from me but Storybook stopped working. The errors are:
|
Another fix would be // eslint-disable-next-line @typescript-eslint/no-var-requires
const { yupResolver } = require('@hookform/resolvers/yup') |
similar issue: vercel/next.js#30750 ? |
Facing the same issue with Next Js, tried @allwd & @Yhozen solutions. Neither worked
If anyone has any other solutions I would love to hear them! EDIT Next.Js versions 11.1.3 and 12.0.1 have fixed the build issue so at least it building for now.... |
Same issue. No solutions presented here works. These did not work: Any other solutions? @jorisre - any updates to report? |
@dsacramone Whilst not ideal, you can see my reply above in that dropping the version of Next down to 12.0.1 (specifically) in package.json and then re-running yarn (or npm) fixed all the build issues for me. As others have linked, this thread over at the Next repo seems to be dealing with the same (or similar) problem: |
can we try nextjs |
Hey @PaulHaze , are you still importing it the same? I did as you suggest and am using 12.0.1, and it did build, but when viewed in a browser, the page doesn't work - as expected if my hookform isn't working. Did you use a special "import" or way to get at it? my error is: excludeEmptyString is not defined |
Nextjs 12.0.3 was released, but it doesn't resolve this issue, unfortunately. |
Yes still this is blocking 😕 |
Same issue. |
downgrading to 12.0.1 fix the issue |
@dsacramone No I think I am just importing it as usual:
That is what I am using to import it. The versions I have in my package.json are:
So far it is working both locally and when I build/deploy it. I hope that is of some use !? :) |
all valid opinions @yordis |
I confirm, that version 7.21.1 and Next 12.0.7 works well. 7.21.1. Thanks a lot. |
|
I believe the root cause for the CRA issue is that RHF uses the I'm surprised RHF isn't using |
For me neither |
This ensures that Node always treats the ESM output as ESM, despite the package.json (implicit) type of commonjs. Bundlers that expect ESM, such as Next v12, no longer explode when encountering this module. Refs react-hook-form#7095 Refs react-hook-form#7088 Refs react-hook-form/resolvers#271 Refs vercel/next.js#30750
This ensures that Node always treats the ESM output as ESM, despite the package.json (implicit) type of commonjs. Bundlers that expect ESM, such as Next v12, no longer explode when encountering this module. Refs react-hook-form#7244 Refs react-hook-form#7095 Refs react-hook-form#7088 Refs react-hook-form/resolvers#271 Refs vercel/next.js#30750
I verified that react-hook-form/react-hook-form#7261 works for NextJS 12.0.7, but I don't have a Storybook or CRA project offhand to test the backward-compatibility. |
thank you again @evocateur |
) * build(esm): Use explicit .mjs extension for ESM This ensures that Node always treats the ESM output as ESM, despite the package.json (implicit) type of commonjs. Bundlers that expect ESM, such as Next v12, no longer explode when encountering this module. Refs #7244 Refs #7095 Refs #7088 Refs react-hook-form/resolvers#271 Refs vercel/next.js#30750 * fix(esm-interop): Import non-ESM React as default
beta: |
the above beta pass test for my with CRA and nextjs thank so much @evocateur life saver. |
v7.21.3-beta.0 works perfectly! |
oh wow, I didn't check evocateur's profile, he is the creator/author of Lerna. Respect 🎩 |
Many thanks @bluebill1049 & @evocateur 🙏 |
thanks @Alexandredc All effort and credit goes to evocateur ❤️ |
… (#7262) * build(esm): Use explicit .mjs extension for ESM, with CJS interop (#7261) * build(esm): Use explicit .mjs extension for ESM This ensures that Node always treats the ESM output as ESM, despite the package.json (implicit) type of commonjs. Bundlers that expect ESM, such as Next v12, no longer explode when encountering this module. Refs #7244 Refs #7095 Refs #7088 Refs react-hook-form/resolvers#271 Refs vercel/next.js#30750 * fix(esm-interop): Import non-ESM React as default * 7.21.3-beta.0 * update with v2 compress * fix lint error and update packages Co-authored-by: Daniel Stockman <5605+evocateur@users.noreply.github.com>
@bluebill1049 I'm merely the longtime maintainer (presently a bit delinquent), not the author, of Lerna. I appreciate your responsiveness and effort as creator and maintainer of React Hook Form! |
hopefully, this is the last time i close this issue: https://github.com/react-hook-form/react-hook-form/releases/tag/v7.22.0 🙏 |
@Yhozen Solution Worked, Thank you 🎉 const { yupResolver } = require('@hookform/resolvers/yup'); My versions : {
"@hookform/resolvers": "^2.8.8",
"next": "^12.1.4",
"react-hook-form": "^7.29.0",
"yup": "^0.32.11"
} |
This reoccur in next js v13 when I am trying to use zodResolver and try running yarn build with nextjs 13. I've also created a ticket in vercel Link - vercel/next.js#43121 "dependencies": {
"@heroicons/react": "^2.0.13",
"@hookform/error-message": "^2.0.1",
"@hookform/resolvers": "^2.9.10",
"@tanstack/react-query": "^4.16.1",
"@types/node": "18.11.9",
"@types/react": "18.0.25",
"@types/react-dom": "18.0.9",
"aws-sdk": "^2.1257.0",
"axios": "^1.1.3",
"clsx": "^1.2.1",
"dotenv": "^16.0.3",
"eslint": "8.27.0",
"eslint-config-next": "^13.0.3",
"flowbite": "^1.5.4",
"flowbite-react": "^0.3.5",
"mongodb": "^4.11.0",
"multer": "^1.4.5-lts.1",
"next": "^13.0.3",
"next-connect": "^0.13.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-dropzone": "^14.2.3",
"react-hook-form": "^7.39.4",
"react-tailwindcss-select": "^1.3.3",
"typescript": "4.9.3",
"zod": "^3.19.1"
}, ReferenceError: File is not defined
at 3608 (/Users/arifrahman/Code/personal/pokedex-nextjs13/.next/server/app/pokemon/create/page.js:412:31)
at __webpack_require__ (/Users/arifrahman/Code/personal/pokedex-nextjs13/.next/server/webpack-runtime.js:25:42)
at B (/Users/arifrahman/Code/personal/pokedex-nextjs13/node_modules/next/dist/compiled/react-server-dom-webpack/client.js:924:142)
at H (/Users/arifrahman/Code/personal/pokedex-nextjs13/node_modules/next/dist/compiled/react-server-dom-webpack/client.js:922:264)
at /Users/arifrahman/Code/personal/pokedex-nextjs13/node_modules/next/dist/compiled/react-server-dom-webpack/client.js:927:218
|
how do i fix the error in my next13 app
|
I have received your email, thank you!If there is anything important, I will reply to you as soon as I see it...
|
its been fixed , i just had to through the documentation well for the type |
Describe the bug
I've upgraded to NextJS v12 which supports ES modules out of the box and now I'm getting the following error whenever I try to load any page that imports uses
zodResolver
.To Reproduce
@hookform/resolvers
Expected behavior
Import is resolved.
Additional context
"@hookform/resolvers": "^2.8.2"
,"react-hook-form": "^7.18.0"
,"next": "^12.0.2"
.The text was updated successfully, but these errors were encountered: