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
edit: managed to find the cause.... for some reason the json files had been ignoreb by git. Now ot works. Sorry....
I'm using next-intl 4.0.2. I don't use /src/, but I have all code in root. Therefore I placed the i18n folder with request.ts in root, as well as messages folder with sv.json and en.json. But no matter what I do with paths and configurations, I keep getting the same error when deploying to Vercel: Module not found: Can't resolve '../messages'
I only do scoped localization for a particular app, so the relevant layout.tsx file is in /app/appname/[lang]/layout.tsx, and same with the page.tsx
I have read about others having similar issues, but I haven't been able to apply their fixes to my case.
What can I do about this? My current files are these:
/i18n/request.ts:
import { getRequestConfig } from "next-intl/server";
import { hasLocale } from "next-intl";
// Define supported locales as a const array for better type safety
const supportedLocales = ["sv", "en"] as const;
const defaultLocale = "sv";
export default getRequestConfig(async ({ requestLocale }) => {
const requested = await requestLocale;
// Use the new hasLocale helper to validate the locale
const locale = hasLocale(supportedLocales, requested)
? requested
: defaultLocale;
return {
locale,
messages: (await import(`../messages/${locale}.json`)).default,
};
});
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
edit: managed to find the cause.... for some reason the json files had been ignoreb by git. Now ot works. Sorry....
I'm using next-intl 4.0.2. I don't use /src/, but I have all code in root. Therefore I placed the i18n folder with request.ts in root, as well as messages folder with sv.json and en.json. But no matter what I do with paths and configurations, I keep getting the same error when deploying to Vercel:
Module not found: Can't resolve '../messages'
I only do scoped localization for a particular app, so the relevant layout.tsx file is in /app/appname/[lang]/layout.tsx, and same with the page.tsx
I have read about others having similar issues, but I haven't been able to apply their fixes to my case.
What can I do about this? My current files are these:
/i18n/request.ts:
next.config.mjs:
/app/appname/[lang]/layout.tsx:
Beta Was this translation helpful? Give feedback.
All reactions