如何使用 Material-tailwind 解决 next.js 13.5 最新错误?

Jaz*_*lah 6 reactjs next.js next.js13

这是一个简单的错误,我创建了一个 next.js 13.5 最新项目。然后安装material-tailwind。然后在使用时进行测试只需从材料中单击我,在开发模式下它运行完美......但是当我使用yarn build或托管vercel时,它显示错误。当我删除从material-tailwind导入的组件时,它在开发模式下完美运行,并且也完美构建和部署..但是如果我从material-tailwind导入任何组件,它在开发模式下完美工作,但是当尝试构建时,它给出错误,这是错误,

\n
yarn run v1.22.19\n$ next build\n \xe2\x9c\x93 Creating an optimized production build    \n \xe2\x9c\x93 Compiled successfully\n \xe2\x9c\x93 Linting and checking validity of types    \n \xe2\x9c\x93 Collecting page data    \n   Generating static pages (4/5)  [==  ] \nRangeError: Maximum call stack size exceeded\n    at P (/home/abdullah/projects/next/fleet/fleet-frontend-2nd/.next/server/chunks/490.js:10:66159)\n    at l (/home/abdullah/projects/next/fleet/fleet-frontend-2nd/.next/server/chunks/490.js:10:61350)\n    at /home/abdullah/projects/next/fleet/fleet-frontend-2nd/.next/server/chunks/490.js:10:62551\n    at Array.forEach (<anonymous>)\n    at /home/abdullah/projects/next/fleet/fleet-frontend-2nd/.next/server/chunks/490.js:10:62524\n    at Array.forEach (<anonymous>)\n    at a (/home/abdullah/projects/next/fleet/fleet-frontend-2nd/.next/server/chunks/490.js:10:62344)\n    at /home/abdullah/projects/next/fleet/fleet-frontend-2nd/.next/server/chunks/490.js:10:62608\n    at Array.forEach (<anonymous>)\n    at l (/home/abdullah/projects/next/fleet/fleet-frontend-2nd/.next/server/chunks/490.js:10:62301)\n\nError occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error\nRangeError: Maximum call stack size exceeded\n    at P (/home/abdullah/projects/next/fleet/fleet-frontend-2nd/.next/server/chunks/490.js:10:66159)\n    at l (/home/abdullah/projects/next/fleet/fleet-frontend-2nd/.next/server/chunks/490.js:10:61350)\n    at /home/abdullah/projects/next/fleet/fleet-frontend-2nd/.next/server/chunks/490.js:10:62551\n    at Array.forEach (<anonymous>)\n    at /home/abdullah/projects/next/fleet/fleet-frontend-2nd/.next/server/chunks/490.js:10:62524\n    at Array.forEach (<anonymous>)\n    at a (/home/abdullah/projects/next/fleet/fleet-frontend-2nd/.next/server/chunks/490.js:10:62344)\n    at /home/abdullah/projects/next/fleet/fleet-frontend-2nd/.next/server/chunks/490.js:10:62608\n    at Array.forEach (<anonymous>)\n    at l (/home/abdullah/projects/next/fleet/fleet-frontend-2nd/.next/server/c\n \xe2\x9c\x93 Generating static pages (5/5) \n\n> Export encountered errors on following paths:\n        /page: /\nerror Command failed with exit code 1.\ninfo Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.\n
Run Code Online (Sandbox Code Playgroud)\n

这是我在 page.js 文件中的测试代码

\n
"use client";\n\nimport { Button } from "@material-tailwind/react";\n\nconst Home = () => {\n    return (\n        <main>\n            <Button>Click me</Button>\n        </main>\n    );\n};\n\nexport default Home;\n\n
Run Code Online (Sandbox Code Playgroud)\n

小智 0

让我以此作为序言,我知道这并不能 100% 解决您的问题,但在官方修复发布之前,它可能有助于暂时修复它。

这似乎与 Next.js 版本 13.5 有关 - 同样的事情也发生在我身上。我今天花了几个小时试图找出解决方案 - 很多其他人说增加限制,--stack-size=_____但这对我不起作用。最终,我的版本降级工作完美无缺,并且第一次构建。

为此:

  1. rm -r node_modules在命令行上使用完全删除您的node_modules文件夹。(您不需要删除 .next 文件夹,但如果这不起作用,请将其也删除。)
  2. 在您的 中package.json,将下一个版本设置为 13.5.X 以外的版本 - 我使用 13.4.19,因为那是我的最后一个稳定版本。
  3. npm install从命令行运行
  4. 重新运行您的构建,如果您不使用 v13.5,它应该会成功构建

希望这可以帮助您启动并运行,直到问题得到正式修复!