Problem with deploying ssg and ssr pages using serverless and next-i18next - DELETED
I have the same problem. Any news about it?
Well I think my problem also relates to this. Althought Iam using SST, Serverless Stack, to deploy it uses pretty much same cdk construct from this repository. Lambda crashes with:
ERROR Error: Cannot find module '/var/task/next-i18next.config.js' at webpackEmptyContext (/var/task/chunks/474.js:9:10) at /var/task/chunks/638.js:248:72 { code: 'MODULE_NOT_FOUND'} | 2021-12-06T20:13:37.133Z bbbe90c8-e91c-4d20-b9bf-52c098b26d73 ERROR Error: Cannot find module '/var/task/next-i18next.config.js' at webpackEmptyContext (/var/task/chunks/474.js:9:10) at /var/task/chunks/638.js:248:72 { code: 'MODULE_NOT_FOUND' }
Got it working. I simply needed to include next-i18next.config.js and give it as parameter to serverSideTranslation. Better explanation at the link:
https://githubmemory.com/repo/aws-amplify/amplify-console/issues/2111?page=1
I had the same issue but I've just resolved it based on @Mikko-AM 's answer.
my old code was like this
// pages/_app.tsx
(...)
export default appWithTranslation(MyApp);
// pages/index.tsx
(...)
export async function getStaticProps({ locale }) {
return { props: { ...(await serverSideTranslations( locale, ['common']) } };
}
And I fixed like this.
// pages/_app.tsx
import i18nConfig from '../next-i18next.config';
(...)
export default appWithTranslation(MyApp, i18nConfig);
// pages/index.tsx
import i18nConfig from '../next-i18next.config';
(...)
export async function getStaticProps({ locale }) {
return { props: { ...(await serverSideTranslations( locale, ['common'], i18nConfig) } };
}
Weird problem but the solutions by @Mikko-AM and @kyun worked pretty well in my case.