You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems like using the --turbo flag with the Nextjs dev server is currently not possible. There appears to be a mismatch with how the config file is resolved at different points in the dev server operation.
If I start the Next dev server without --turbo and the following config, everything works great:
/** * This works for Webpack * * But NOT for starting the Turbo dev server */constwithNextIntl=createNextIntlPlugin('i18n/request.ts',);
But this does NOT work with turbo:
Error: [next-intl] Could not find i18n config at i18n/request.ts, please provide a valid path.
Second, I tried setting up another config file path, starting from src/ this time:
/** * This works for STARTING the Turbo dev server * * But this will throw an error in layout.tsx when loading localhost:3000 */constwithNextIntl=createNextIntlPlugin('src/i18n/request.ts',);
The dev server starts just fine, but once I load the project in the browser it throws an error in layout.tsx:
✓ Compiled / in 1295ms
⨯ Error: Couldn't find next-intl config file. Please follow the instructions at https://next-intl.dev/docs/getting-started/app-router
at RootLayout (src/app/layout.tsx:20:31)
18 | children: React.ReactNode
19 | }) {
> 20 | const locale = await getLocale();
This could be related to how I structure my projects. All Nextjs frontend code is contained within the src/ dir. Check package.json in the repro repository to see the scripts I am using to start Next.
Verifications
I've verified that the problem I'm experiencing isn't covered in the docs.
It seems like there are the following issues here:
The path to i18n/request.ts needs to be relative (e.g. ./src/i18n/request.ts) or simply removed (since you use the default)
The [directory] option for next dev doesn't work properly, you can resolve this by moving next.config.ts one folder up and calling next dev --turbo instead
I think what next-intl could do better is:
Consistently handle relative paths (currently your input passes the validation but fails at runtime)
Maybe support the [directory] option (I didn't even know this was supported, it's the first time I saw it)
But with the steps mentioned above you should be able to work around the issue for now.
Gotcha, that makes sense. I really appreciate the help here!
I tried digging through the next-intl code and debugging but I think Turbopack strips out any logging from node modules, which made it extremely difficult.
Description
It seems like using the
--turbo
flag with the Nextjs dev server is currently not possible. There appears to be a mismatch with how the config file is resolved at different points in the dev server operation.If I start the Next dev server without
--turbo
and the following config, everything works great:But this does NOT work with turbo:
Second, I tried setting up another config file path, starting from
src/
this time:The dev server starts just fine, but once I load the project in the browser it throws an error in layout.tsx:
This could be related to how I structure my projects. All Nextjs frontend code is contained within the
src/
dir. Checkpackage.json
in the repro repository to see the scripts I am using to start Next.Verifications
Mandatory reproduction URL
https://github.com/joshverd/next-intl-bug-repro
Reproduction description
npm i
src/next.config.ts
npm run dev-turbo
Expected behaviour
I expect the dev server to 1) start properly and 2) render my layout.tsx and page.tsx files correctly.
The text was updated successfully, but these errors were encountered: