我正在尝试构建我的 react NEXT JS 应用程序,但是在我运行之后
npm 运行构建
我收到此错误:
Error occurred prerendering page "/it/landing". Read more: https://nextjs.org/docs/messages/prerender-error
Error: next-i18next was unable to find a user config
. . .
Error: Export encountered errors on following paths:
/it/landing
我尝试从landing/index.tsx 中的getStaticProps 函数中删除serverSideTranslations 方法
看起来像这样
export const getStaticProps = async ({ locale }) => {
return {
props: {
...(await serverSideTranslations(locale, [
"notifier",
"home",
])),
}
}
}
在我在 serverSideTranslations 中注释代码后,应用程序可以正确构建。
我还有另一个页面,它同时包含 getStaticPaths 和 getStaticProps,但它工作正常,没有错误。
// register/[encoded].tsx
export const getStaticProps = async ({ locale }) => {
return {
props: {
...(await serverSideTranslations(locale, [
"notifier"
])),
}
}
}
我是 react 和下一个 js 开发的新手,所以也许我遗漏了一些东西,但它看起来像是一种奇怪的行为。
如果我运行代码有效
npm 运行开发