shopifyi18nextshopify-appreact-i18nextremix.run

Facing error while implementing translation in Remix app


I'm trying to implement translation in my remix app using remix-i18next following this guideline.

But then started getting this following error:

18:39:54 │ remix      │ /home/Desktop/shopify/my-app/build/index.js:428
18:39:54 │ remix      │ var import_i18next_fs_backend = __toESM(require("i18next-fs-backend")), import_node_path = require("node:path"), import_server2 = 
require("remix-i18next/server");
18:39:54 │ remix      │                                                                                                                                   ^
18:39:54 │ remix      │ Error [ERR_REQUIRE_ESM]: require() of ES Module 
/home/Desktop/shopify/my-app/node_modules/remix-i18next/build/server.js from 
/home/Desktop/shopify/my-app/build/index.js not supported.
18:39:54 │ remix      │ Instead change the require of server.js in 
/home/Desktop/shopify/my-app/build/index.js to a dynamic import() which is available in all CommonJS 
modules.
18:39:54 │ remix      │     at Object.<anonymous> (/home/Desktop/shopify/my-app/build/index.js:428:131)
18:39:54 │ remix      │     at async run 
(/home/Desktop/shopify/my-app/node_modules/@remix-run/serve/dist/cli.js:112:15)

How can I fix this? Thanks!


Solution

  • I created an issue regarding this in the official git repo that you can find here.

    According to the repository owner Sergio it's happening due to conflict between ESM and CJS that were used in some packages and it's recommended to use Vite since the classic compiler is going to be removed in the near future.