Skip to content
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

Next js 13 react-hook-form build issue #43121

Closed
1 task done
ayepRahman opened this issue Nov 19, 2022 · 2 comments
Closed
1 task done

Next js 13 react-hook-form build issue #43121

ayepRahman opened this issue Nov 19, 2022 · 2 comments
Labels
bug Issue was opened via the bug report template.

Comments

@ayepRahman
Copy link

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 21.6.0: Mon Aug 22 20:19:52 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T6000
Binaries:
  Node: 18.12.1
  npm: 8.19.2
  Yarn: 1.22.19
  pnpm: N/A
Relevant packages:
  next: 13.0.5-canary.2
  eslint-config-next: 13.0.4
  react: 18.2.0
  react-dom: 18.2.0

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

I am using "react-hook-form": "^7.39.4", and "@hookform/resolvers": "^2.9.10", in the latest nextjs v13. Running on dev work perfectly, up until I tried running $ yarn build and I am facing some issue regarding File not found. When I try on nextks v12, it works perfectly.

ReferenceError: File is not defined
    at 7884 (/Users/arifrahman/Code/personal/pokedex-nextjs13/.next/server/app/pokemon/create/page.js:694:31)
    at __webpack_require__ (/Users/arifrahman/Code/personal/pokedex-nextjs13/.next/server/webpack-runtime.js:25:43)
    at B (/Users/arifrahman/Code/personal/pokedex-nextjs13/node_modules/next/dist/compiled/react-server-dom-webpack/client.js:924:142)
    at C (/Users/arifrahman/Code/personal/pokedex-nextjs13/node_modules/next/dist/compiled/react-server-dom-webpack/client.js:921:88)
    at ae (/Users/arifrahman/Code/personal/pokedex-nextjs13/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:103:118)
    at Z (/Users/arifrahman/Code/personal/pokedex-nextjs13/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:104:91)
    at be (/Users/arifrahman/Code/personal/pokedex-nextjs13/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:106:98)
    at ae (/Users/arifrahman/Code/personal/pokedex-nextjs13/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:99:213)
    at Z (/Users/arifrahman/Code/personal/pokedex-nextjs13/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:104:91)
    at Z (/Users/arifrahman/Code/personal/pokedex-nextjs13/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:104:191)

Error occurred prerendering page "/pokemon/create". Read more: https://nextjs.org/docs/messages/prerender-error
ReferenceError: File is not defined
    at 7884 (/Users/arifrahman/Code/personal/pokedex-nextjs13/.next/server/app/pokemon/create/page.js:694:31)
    at __webpack_require__ (/Users/arifrahman/Code/personal/pokedex-nextjs13/.next/server/webpack-runtime.js:25:43)
    at B (/Users/arifrahman/Code/personal/pokedex-nextjs13/node_modules/next/dist/compiled/react-server-dom-webpack/client.js:924:142)
    at C (/Users/arifrahman/Code/personal/pokedex-nextjs13/node_modules/next/dist/compiled/react-server-dom-webpack/client.js:921:88)
    at ae (/Users/arifrahman/Code/personal/pokedex-nextjs13/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:103:118)
    at Z (/Users/arifrahman/Code/personal/pokedex-nextjs13/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:104:91)
    at be (/Users/arifrahman/Code/personal/pokedex-nextjs13/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:106:98)
    at ae (/Users/arifrahman/Code/personal/pokedex-nextjs13/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:99:213)
    at Z (/Users/arifrahman/Code/personal/pokedex-nextjs13/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:104:91)
    at Z (/Users/arifrahman/Code/personal/pokedex-nextjs13/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:104:191)
info  - Generating static pages (154/154)
  "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.5-canary.2",
    "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"
  },
```perfectly

### Expected Behavior

Expect to build succesfully when running `$ yarn build` with the latest react-hook-formsuccessfully

### Link to reproduction - Issues with a link to complete (but minimal) reproduction code will be addressed faster

https://github.com/ayepRahman/pokedex-nextjs13

### To Reproduce

`$ git clone https://github.com/ayepRahman/pokedex-nextjs13 && yarn && yarn build`
@ayepRahman ayepRahman added the bug Issue was opened via the bug report template. label Nov 19, 2022
@ayepRahman
Copy link
Author

The issue lies with using zod and using instance of file.

@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

1 participant