NextJS Translation Error

Hello Guys, I am facing a problem on some of my pages, for some reason I am getting the below error when accessing a route with :splat on the URL mapping. I have tried a couple of solution like adding the included_files = [“next-i18next.config.js”, “public/locales/**”] option on my netlify.toml configuration but have had no luck. Any ideas what might be causing this problem? BTW, the application runs without issues locally and on Vercel. Thanks in advance.`

Jul 6, 11:32:29 PM: 89815405 ERROR   ⨯ Error [ERR_REQUIRE_ESM]: require() of ES Module /var/task/next-i18next.config.js from /var/task/node_modules/next-i18next/dist/commonjs/serverSideTranslations.js not supported.
next-i18next.config.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules. Instead either rename next-i18next.config.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /var/task/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead). at mod.require (/var/task/node_modules/next/dist/server/require-hook.js:65:28)
    at /var/task/node_modules/next-i18next/dist/commonjs/serverSideTranslations.js:100:46 {

Without a site name, we can’t check much.

Sorry, the site name is dev-blackmamba.

Have you tried upgrading to next.js 13.5+ and Next.js Runtime v5? We currently do not provide support with Runtime v4.

Actually, the version I have running right now it is using runtime 4 with 13.4 which does not have the issue. If you take a look at the build under branch “miguel-update-versions”, you would see the v5 runtime and latest nextjs… this combination is the one causing the error shown on the first message.

Hello, any ideas what could be wrong? I have tried finding what is going on withouth any luck. I just created a simple project deployed under site mike-snow-test-next in which you can replicate the issue. The source code can be found on: GitHub - themikesnow/netlify-nextjs

No issues:
Path with translation issue:

Please, let me know if you see anything wrong. Thanks in advance.

Anyone have any ideas what might be going on? Any inputs or hints are welcome… still struggling with this issue and right now have no other ideas to try. Thanks in advance.

Could you try changing your project to ESM? That is, add type: module to package.json and convert all require statements into import.

I have tried to change the project to ESM but then a bunch of other stuff stop working. I am very curios to know if there are other people having the same issue as me or if I have something wrong on my config. On the example repo there is not a lot of custom code and the issue is reproducible, it is weird I am the only one with this issue.

Interesting. I’ve asked the devs to take a look here.