最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Vercel Next.js build error while prerendering pages - Stack Overflow

programmeradmin2浏览0评论

I'm running Vercel pilation on my website and I can't get rid of the pre-rendering error on export. does anyone know the reason for this to happen and can help me with this? my github with all code:

for each page have a error as above:

    Error occurred prerendering page "/resume". Read more: 
Error: Minified React error #321; visit .html?invariant=321 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.

Error: Export encountered errors on following paths:
21:20:09.541        /
21:20:09.541        /404
21:20:09.541        /500
21:20:09.541        /experiences
21:20:09.542        /resume
21:20:09.542        /skills

i dont have a custom 404 or 500 page.

I'm running Vercel pilation on my website and I can't get rid of the pre-rendering error on export. does anyone know the reason for this to happen and can help me with this? my github with all code: https://github./M0rilla/MyProfile

for each page have a error as above:

    Error occurred prerendering page "/resume". Read more: https://nextjs/docs/messages/prerender-error
Error: Minified React error #321; visit https://reactjs/docs/error-decoder.html?invariant=321 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.

Error: Export encountered errors on following paths:
21:20:09.541        /
21:20:09.541        /404
21:20:09.541        /500
21:20:09.541        /experiences
21:20:09.542        /resume
21:20:09.542        /skills

i dont have a custom 404 or 500 page.

Share Improve this question edited May 30, 2021 at 15:03 Gustavo Morilla asked May 30, 2021 at 0:26 Gustavo MorillaGustavo Morilla 3421 gold badge4 silver badges11 bronze badges 5
  • 1 The reason this is happening (invalid react hook call) is stated directly in the error link. If you aren't sure why your react hook call is invalid after reading the information there, make sure to put the code of your /resume page here, otherwise there's no way we can help. – dominicm00 Commented May 30, 2021 at 0:30
  • I added the code for one of my pages for viewing. All pages contained in the "pages" directory are showing this error including 404 and 500 that I did not create – Gustavo Morilla Commented May 30, 2021 at 3:01
  • There's a link to my github with the project on the question! – Gustavo Morilla Commented May 30, 2021 at 3:14
  • 2 While I can't test your code with a Vercel deployment, your issue is almost certainly caused by you mitting your node_modules folder and .next build artifacts to git, which you should never do. You should create a .gitignore file with node_modules/ and .next/. See docs.github./en/github/getting-started-with-github/… and stackoverflow./questions/1274057/… – dominicm00 Commented May 30, 2021 at 15:44
  • can you create a answer with this ment? my production code is now working fine! adding the gitignore file and deleting these folders from repo saved me. thank you! – Gustavo Morilla Commented May 31, 2021 at 15:53
Add a ment  | 

2 Answers 2

Reset to default 5

Vercel does some custom work in regards to next builds, so mitting the .next build artifacts from your local machine or your node_modules folder can interfere with the build in unpredictable ways that give seemingly nonsensical error messages. Make sure to not mit either .next or node_modules to avoid this behavior.

Have you tried checking these cases:

  • Make sure to move any non-pages out of the pages folder
  • Check for any code that assumes a prop is available even when it might not be. e.g., have default data for all dynamic pages' props.
  • Check for any out of date modules that you might be relying on
  • Make sure your ponent handles fallback if it is enabled in getStaticPaths. Fallback docs
  • Make sure you are not trying to export (next export) pages that have server-side rendering enabled (getServerSideProps)

(source)

发布评论

评论列表(0)

  1. 暂无评论