Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build error when using standard next js alias #1703

Open
3 tasks done
mr-scrpt opened this issue Feb 6, 2025 · 1 comment
Open
3 tasks done

Build error when using standard next js alias #1703

mr-scrpt opened this issue Feb 6, 2025 · 1 comment
Labels
bug Something isn't working unconfirmed Needs triage. upstream-issue This issue is caused by an upstream dependency (e.g. Next.js)

Comments

@mr-scrpt
Copy link

mr-scrpt commented Feb 6, 2025

Description

Throughout the project I use the @ alias that next js provides, and it works in the development stage configuration as well

import { getRequestConfig } from "next-intl/server";
import { i18n, isValidLocale } from "./domain/type";
import { routing } from "./routing";

export default getRequestConfig(async ({ requestLocale }) => {
  let locale = await requestLocale;

  if (!locale || !isValidLocale(locale)) {
    locale = routing.defaultLocale;
  }

  return {
    locale,
    messages: (
      await import(`@/shared/dictionary/${i18n.dictionaryPath}/${locale}.json`)
    ).default,
  };
});

But as soon as I try to build the pnpm build project I get an error

   ▲ Next.js 15.1.5

   Creating an optimized production build ...
 ✓ Compiled successfully
 ✓ Linting and checking validity of types
 ✓ Collecting page data
Error occurred prerendering page "/en/contact". Read more: https://nextjs.org/docs/messages/prerender-error
Error: Cannot find module './dictionary/en.json'
    at /home/mr/Project/work/maksim/mz-partners/next/.next/server/chunks/912.js:1:115
    at async /home/mr/Project/work/maksim/mz-partners/next/.next/server/chunks/912.js:1:5031
    at async /home/mr/Project/work/maksim/mz-partners/next/.next/server/chunks/256.js:2:80931
    at async /home/mr/Project/work/maksim/mz-partners/next/.next/server/chunks/256.js:2:81683
    at async /home/mr/Project/work/maksim/mz-partners/next/.next/server/chunks/256.js:2:82025
    at async n (/home/mr/Project/work/maksim/mz-partners/next/.next/server/chunks/912.js:1:6108)
Export encountered an error on /[locale]/contact/page: /en/contact, exiting the build.
 ⨯ Static worker exited with code: 1 and signal: null
 ELIFECYCLE  Command failed with exit code 1.

Verifications

Mandatory reproduction URL

On any project

Reproduction description

  1. Install next
  2. Install and configure next-intl

Expected behaviour

should work

@mr-scrpt mr-scrpt added bug Something isn't working unconfirmed Needs triage. labels Feb 6, 2025
@amannn
Copy link
Owner

amannn commented Feb 7, 2025

Maybe this is a Next.js bug, dynamic imports is nothing that next-intl has any control over.

I've personally always used relative paths which work fine.

@amannn amannn added the upstream-issue This issue is caused by an upstream dependency (e.g. Next.js) label Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working unconfirmed Needs triage. upstream-issue This issue is caused by an upstream dependency (e.g. Next.js)
Projects
None yet
Development

No branches or pull requests

2 participants