./i18n.js Critical dependency: the request of a dependency is an expression
See original GitHub issueToday after doing some package updates e.g. next@12.1.6 next-translate crashes while trying to load the locale. Im importing my locales from a package inside my monorepo with:
./i18n.js
loadLocaleFrom: (locale, namespace) =>
import(`locales/${locale}/${namespace}`).then((m) => m.default),
That worked for me for like 2 months now. But now i get following error:
./i18n.js
Critical dependency: the request of a dependency is an expression
After a while of trial and error i got my code working with:
loadLocaleFrom: (locale, namespace) =>
require(`locales/${locale}/${namespace}`),
Is the error here with me or is there a package error?
Issue Analytics
- State:
- Created a year ago
- Reactions:28
- Comments:29 (10 by maintainers)
Top Results From Across the Web
Issues - GitHub
./i18n.js Critical dependency: the request of a dependency is an expression #851. Open.
Read more >Critical dependency: the request of a dependency is an ...
I think problem is with my configuration. next.config.js const {i18n} = require('./next-i18next.config ...
Read more >the request of a dependency is an expression nextjs - You.com
I am getting three warning messages when importing request in a barebone webpack project. A minimal example to reproduce the bug is available...
Read more >kglogins - Netlify Support Forums
i18n, }. After running. npm run build. I get this error: next build ... Critical dependency: the request of a dependency is an...
Read more >lingui/js-lingui - Gitter
... Critical dependency: the request of a dependency is an expression ../node_modules/@lingui/macro/node_modules/babel-plugin-macros/dist/index.js 62:46-53 ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Of course, it is not the right solution, but until we find the best way to fix it (all suggestions are welcome), you can do a workaround and not use the
loadLocaleFrominside i18n.js and overwrite the default:Any suggestions from anyone on how to fix it internally in the library? Thanks!
We have the same problem and also fixed it with
require(like https://github.com/vinissimus/next-translate/issues/851#issuecomment-1116090210).We also had to catch the error on the
requirebecause not all of the files exist (we implement a fallback logic for country-specific locales like “es-CL” and then fallback to English):