我在整个页面上都使用 MUI,但其中一个页面似乎无法正常工作。在开发模式(下一个开发)上,一切正常,在生产构建(下一个构建 + 下一个启动)中,URL 上的第一个请求会抛出错误 500。错误如下。有趣的是,页面实际上在初始请求达到 500 后就可以正常工作,但页面会正常呈现,最终用户根本不会发现任何问题。然而对于机器人来说,这是一个严重的错误。
错误:
TypeError: Cannot read properties of undefined (reading 'call')
at t (C:\Develop\carcheck-frontend\.next\server\webpack-runtime.js:1:128)
at F (C:\Develop\carcheck-frontend\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:12:91937)
at $ (C:\Develop\carcheck-frontend\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:12:90488)
at rC (C:\Develop\carcheck-frontend\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:12:33840)
at n$ (C:\Develop\carcheck-frontend\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:12:59861)
at nj (C:\Develop\carcheck-frontend\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:12:64628)
at nO (C:\Develop\carcheck-frontend\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:12:64035)
at n$ (C:\Develop\carcheck-frontend\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:12:62224)
at nj (C:\Develop\carcheck-frontend\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:12:64628)
at nP (C:\Develop\carcheck-frontend\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:12:56390)
我相信它与 MUI + 服务器渲染有某种关系。但我不确定具体如何。 如果我将组件模板更改为这样,则可以正常工作:
<main>
<h1 style={{ visibility: 'hidden' }}>{t('vehicleHistoryReport')}</h1>
<Grid container spacing={0} style={{ marginTop: 30 }}>
<FAQ lng={lng} />
</Grid>
</main>
如果我将其更改为:
import {Container}} from '@mui/material'
<main>
<Container maxWidth="lg">
<h1 style={{ visibility: 'hidden' }}>{t('vehicleHistoryReport')}</h1>
<Grid container spacing={0} style={{ marginTop: 30 }}>
<FAQ lng={lng} />
</Grid>
</Container>
</main>
它会抛出错误。 上面显然是最小的示例,生产页面错误也可以在以下位置找到:https://rb.gy/o6rjhu
浏览器中的网络选项卡:
我的版本:
其他人有类似的问题吗?或者有人可以指出我正确的方向,我该如何进一步调试?
出于某种原因
yarn upgrade
解决了我的问题,不确定到底是什么问题,但现在正在工作。